ascii编码 ios
2015-05-21 12:30:17 u012143568 阅读数 454
// NSString to ASCII
NSString *string = @"A";
int asciiCode = [string characterAtIndex:0]; // 65
iOS编码
2016-05-06 16:37:13 xuchaovip 阅读数 247
1.定义通知名字
类名+xxxx+Notification

在OC中定义在.m中,extern在.h中


2.定义枚举名字
类名+xxxx+style type...


3.注释都在后边//xxxx

4.setter写在后边

5.函数的return如果创建返回的话中间使用一个空格, 其他情况不用加空格


6 命名

@property (nonatomic, strong) UILabel *statusLabel;

@property (nonatomic, strong) CALayer *backgroundLayer;
@property (nonatomic, strong, readonly) NSTimer *fadeOutTimer;

@property (nonatomic, readonly) CGFloat visibleKeyboardHeight;

@property (strong, nonatomic) UIImage *errorImage UI_APPEARANCE_SELECTOR;   
@property (strong, nonatomic) UIView *viewForExtension UI_APPEARANCE_SELECTOR; 

@property (assign, nonatomic) UIOffset offsetFromCenter

@property (assign, nonatomic) SVProgressHUDStyle defaultStyle


方法名: 动词+xxxx

set reset update show pop dismiss push regist move create setup


定义数组,字典集合类型使用xxxs 如HTTPHeaders

定义Block
// 方法参数带Block


7 方法顺序相同功能,参数多的放在下边

+ (void)show ;

+ (void)showWithMaskType:(SVProgressHUDMaskType)maskType;


8 被调用的方法写在下边

updateHUDFrame {

[self updateBlurBounds];

}

updateBlurBounds {

}


9 注释一组的 使用/**/

/* The initializers available to subclasses. See further below for additional init methods.
*/

注释单个的使用

//

定义的枚举, .h中的属性 都要有注释



iOS编码
2015-05-30 13:52:59 gaoyuqiang30 阅读数 248

gbk

NSStringEncoding enc =CFStringConvertEncodingToNSStringEncoding(kCFStringEncodingGB_18030_2000);

utf8

NSUTF8StringEncoding

iso_8891

NSISOLatin1StringEncoding

编码

      %2b%2b%2b是url编码,如果是3个代表一个汉字,是Utf8;2个代表汉字,是gbk.

NSString *dataUTF8 = [@"测试"stringByAddingPercentEscapesUsingEncoding:enc];

或者

NSString* test =  (__bridge_transferNSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault,  (__bridgeCFStringRef)@"测试"NULL,  (CFStringRef)@"!*'();:@&=+$,/?%#[]",kCFStringEncodingUTF8);


解码

    NSString* c = [bstringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];


NSString 与 NSData互相转化

    NSData* data = [@"haha"dataUsingEncoding:NSUTF8StringEncoding];

    NSString* str = [[NSStringalloc]initWithData:dataencoding:NSUTF8StringEncoding];


从Utf8转成gbk

      NSString* a = [@"你好" stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

      NSString* b = [a stringByReplacingPercentEscapesUsingEncoding:gbk];

或者

    NSString* a = [@"你好" stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    NSString* b = [a stringByReplacingPercentEscapesUsingEncoding:gbk];


结果:浣犲ソ

从gbk转成utf8 同理,不过结果 为nil



2017-07-07 14:14:00 weixin_33819479 阅读数 8
// NSString to ASCII
NSString *string = @"A";
int asciiCode = [string characterAtIndex:0]; //65

//ASCII to NSString
int asciiCode = 65;
NSString *string =[NSString stringWithFormat:@"%c",asciiCode]; //A

转载于:https://www.jianshu.com/p/bab268226dc0

IOS表情编码

阅读数 465

iOS AutoLayout 编码

阅读数 1234

ios urlecode编码

阅读数 4

iOS FFmpeg+x264 编码

阅读数 27

ios硬件编码

阅读数 26

没有更多推荐了,返回首页