//
实例化对象
NSString *str = [[ NSString alloc ] initWithFormat : @"this is fisrt string" ];
NSLog ( @"%@" ,str);
NSLog ( @"%ld" ,[str length ]); // 调用 length 方法
NSLog ( @"%c" ,[str characterAtIndex : 4 ]); // 指定下标下的位置
NSLog ( @"%@" ,[str substringFromIndex : 4 ]); // 指定下标下的位置开始截取字符串
NSLog ( @"%@" ,[str substringToIndex : 4 ]); // 指定下标下的位置截取到字符串
// 指定位置截取
NSRange sub = NSMakeRange ( 3 , 3 );
NSLog ( @"%@" ,[str substringWithRange :sub]); // 截取指定位置部分
BOOL re = [str isEqualToString : @"nini" ];
NSLog ( @"%@" ,re? @"yes" : @"no ” );
NSLog ( @"%@" ,[str uppercaseString ]);
NSLog ( @"%@" ,[str lowercaseString ]);
NSLog ( @"%@" ,[str capitalizedString ]);
// 转换大小写,首字母变为大写
// - (NSString *)uppercaseString;// 转为大写
// - (NSString *)lowercaseString;// 转为小写
// - (NSString *)capitalizedString;// 首字母大写
//
模拟邮箱登陆缺省账户
NSString *mail = [ NSString stringWithFormat : @"leeson" ];
NSString *code = [ NSString stringWithFormat : @"000000" ];
if (![mail hasSuffix : @"@gmail.com" ]) {
mail = [mail stringByAppendingString : @"@gmail.com" ];
// NSLog(@"%@",mail);
// NSLog(@"%@",code);
}
// 模拟账户是否相等
NSString *old = [ NSString stringWithFormat : @"leeson@gmail.com" ];
NSString *oldCode = [ NSString stringWithFormat : @"111111" ];
if ([mail isEqualToString :old]&&[code isEqualToString :oldCode]) {
NSLog ( @"welcome!login success!" );
} else {
NSLog ( @"sorry!login fail!" );
}
NSString *str = [[ NSString alloc ] initWithFormat : @"this is fisrt string" ];
NSLog ( @"%@" ,str);
NSLog ( @"%ld" ,[str length ]); // 调用 length 方法
NSLog ( @"%c" ,[str characterAtIndex : 4 ]); // 指定下标下的位置
NSLog ( @"%@" ,[str substringFromIndex : 4 ]); // 指定下标下的位置开始截取字符串
NSLog ( @"%@" ,[str substringToIndex : 4 ]); // 指定下标下的位置截取到字符串
// 指定位置截取
NSRange sub = NSMakeRange ( 3 , 3 );
NSLog ( @"%@" ,[str substringWithRange :sub]); // 截取指定位置部分
BOOL re = [str isEqualToString : @"nini" ];
NSLog ( @"%@" ,re? @"yes" : @"no ” );
NSLog ( @"%@" ,[str uppercaseString ]);
NSLog ( @"%@" ,[str lowercaseString ]);
NSLog ( @"%@" ,[str capitalizedString ]);
// 转换大小写,首字母变为大写
// - (NSString *)uppercaseString;// 转为大写
// - (NSString *)lowercaseString;// 转为小写
// - (NSString *)capitalizedString;// 首字母大写
NSString *mail = [ NSString stringWithFormat : @"leeson" ];
NSString *code = [ NSString stringWithFormat : @"000000" ];
if (![mail hasSuffix : @"@gmail.com" ]) {
mail = [mail stringByAppendingString : @"@gmail.com" ];
// NSLog(@"%@",mail);
// NSLog(@"%@",code);
}
// 模拟账户是否相等
NSString *old = [ NSString stringWithFormat : @"leeson@gmail.com" ];
NSString *oldCode = [ NSString stringWithFormat : @"111111" ];
if ([mail isEqualToString :old]&&[code isEqualToString :oldCode]) {
NSLog ( @"welcome!login success!" );
} else {
NSLog ( @"sorry!login fail!" );
}