Classes

The following classes are available globally.

  • @brief Common base class for parsing & writing.

    This class contains the common error-handling code and option between the parser/writer.

    See more

    Declaration

    Objective-C

    @interface SBJsonBase : NSObject {
      NSMutableArray *errorTrace;
      NSUInteger depth;
      NSUInteger maxDepth;
    }

    Swift

    class SBJsonBase : NSObject
  • @brief The JSON parser class.

    JSON is mapped to Objective-C types in the following way:

    @li Null -> NSNull @li String -> NSMutableString @li Array -> NSMutableArray @li Object -> NSMutableDictionary @li Boolean -> NSNumber (initialised with -initWithBool:) @li Number -> NSDecimalNumber

    Since Objective-C doesn’t have a dedicated class for boolean values, these turns into NSNumber instances. These are initialised with the -initWithBool: method, and round-trip back to JSON properly. (They won’t silently suddenly become 0 or 1; they’ll be represented as ‘true’ and ‘false’ again.)

    JSON numbers turn into NSDecimalNumber instances, as we can thus avoid any loss of precision. (JSON allows ridiculously large numbers.)

    See more

    Declaration

    Objective-C

    @interface SBJsonParser : SBJsonBase <SBJsonParser> {
      const char *c;
    }

    Swift

    class SBJsonParser : SBJsonBase, SBJsonParserProtocol
  • @brief The JSON writer class.

    Objective-C types are mapped to JSON types in the following way:

    @li NSNull -> Null @li NSString -> String @li NSArray -> Array @li NSDictionary -> Object @li NSNumber (-initWithBool:) -> Boolean @li NSNumber -> Number

    In JSON the keys of an object must be strings. NSDictionary keys need not be, but attempting to convert an NSDictionary with non-string keys into JSON will throw an exception.

    NSNumber instances created with the +initWithBool: method are converted into the JSON boolean true and false values, and vice versa. Any other NSNumber instances are converted to a JSON number the way you would expect.

    See more

    Declaration

    Objective-C

    @interface SBJsonWriter : SBJsonBase <SBJsonWriter> {
      BOOL sortKeys;
      BOOL humanReadable;
    }

    Swift

    class SBJsonWriter : SBJsonBase, SBJsonWriterProtocol
  • Undocumented

    See more

    Declaration

    Objective-C

    @interface APIRequest : ASIHTTPRequest {
        SEL engineSel;
        id  engineDel;
    }
    
    /** 二次封装的网络返回数据. */
    @property(nonatomic,retain)BSAPIResponse  *response;     
    
    /** 请求唯一标记. */
    @property(nonatomic,assign)int          tagNum;       
    
    /** 调用者回调方法. */
    @property(nonatomic,assign)SEL          controllerSel;
    
    /** 调用者回调对象. */
    @property(nonatomic,weak)id           controllerdDel;
    
    
    /** 设置engine的回调
     *
     * @param del       引擎内部回调对象
     * @param sel       引擎内部回调方法
     */
    - (void)setEngineDel:(id)del sel:(SEL)sel;
    
    //+ (NSString *)stringFromDictionary:(NSDictionary *)dict;
    
    -(BSAPIResponse *)responseFromRequest;
    
    // 判断是否有网络
    +(BOOL)isReachable;
    
    //判断是否有wifi
    +(BOOL) isWIFIRechable;
    
    @end

    Swift

    class APIRequest
  • Undocumented

    See more

    Declaration

    Objective-C

    @interface BSAPIResponse : NSObject 
    
    
    /** 是否从缓存读取 0表示从网络读取. */
    @property(nonatomic)BOOL                 bFromLocalCache;
    
    /** 网络请求返回值 0表示从网络读取正常. */
    @property(nonatomic,assign)NSInteger     retCode;
    
    /** 错误信息 */
    @property(nonatomic,retain)NSString      *errMsg;
    
    /** 请求唯一标记 */
    @property(nonatomic,assign)NSInteger     seqNum;
    
    /** 请求返回json串 */
    @property(nonatomic,retain)NSDictionary  *jsonResponse;
    
    /** 网络返回原始数据 */
    @property(nonatomic, retain)NSData      *dataResponse;
    
    /** 网络请求原始状态码 */
    @property(nonatomic, assign)NSInteger   resStatusCode;
    
    @end

    Swift

    class BSAPIResponse : NSObject
  • Undocumented

    See more

    Declaration

    Objective-C

    @interface JHTWIPDetector : NSObject
    
    
    + (void)getLANIPAddressWithCompletion:(void (^)(NSString *IPAddress))completion;
    
    + (void)getWANIPAddressWithCompletion:(void(^)(NSString *IPAddress))completion;
    
    // 内网IP
    + (NSString *)getLANIPAddress;
    
    // 外网IP
    + (void)getWANIPAddress:(void(^)(NSString *IPAddress))completion;
    
    @end

    Swift

    class JHTWIPDetector : NSObject
  • 网络请求引擎,处理网络数据加载

    See more

    Declaration

    Objective-C

    @interface NetEngine : NSObject

    Swift

    class NetEngine : NSObject