Xcode 6 不支持32位的情况 解决方案 $(ARCHS_STANDARD_32_BIT)
字符串分割
NSArray * industrArray = [self.personnalInfo objectForKey:@"SelIndustry"];
NSMutableArray * tempArray = [[NSMutableArray alloc]init];
if ([industrArray count] != 0) {
for (id index in industrArray) {
for (NSDictionary * dict in _industryListArray) {
if (index == [dict objectForKey:@"ID"] ) {
NSString * str = [dict objectForKey:@"IndustryName"];
[tempArray addObject:str];
}
}
}
_industrLabel.text = [tempArray componentsJoinedByString:@"/"];
使用AFNetWorking判断网络状况
[[AFNetworkReachabilityManager sharedManager]startMonitoring];
[[AFNetworkReachabilityManager sharedManager] setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
NSLog(@"%d", status);
switch (status) {
case AFNetworkReachabilityStatusNotReachable:
{
NSLog(@"暂无网络");
UIAlertView * alterView = [[UIAlertView alloc]initWithTitle:@"温馨提示" message:@"暂无网络" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
[alterView show];
}
break;
case AFNetworkReachabilityStatusReachableViaWWAN:
{
NSLog(@"蜂窝网络开启");
[self requestData];
}
break;
case AFNetworkReachabilityStatusReachableViaWiFi:
{
NSLog(@"WIFI网络开启");
[self requestData];
}
default:
break;
}
}];
判断本机IP
struct hostent *host_entry = gethostbyname("api.turetop.com");
char *buff;
buff = inet_ntoa(*((struct in_addr *)host_entry->h_addr_list[0]));
NSLog(@"%s",buff);
使用SDWebImage清楚缓存
[[SDImageCache sharedImageCache] clearDisk];
[[SDImageCache sharedImageCache] clearMemory];
手机号码验证
+ (BOOL) validateMobile:(NSString *)mobile
{
//手机号以13, 15,18开头,八个 \d 数字字符
NSString *phoneRegex = @"^((13[0-9])|(15[^4,\\D])|(18[0,0-9]))\\d{8}$";
NSPredicate *phoneTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",phoneRegex];
return [phoneTest evaluateWithObject:mobile];
}
/********************************************************************************************************************/
StoryBoard传值
1、可用单例类进行传值;
2、if ([segue.identifier isEqualToString:@"PushBrandName"]) {
id theSegue = segue.destinationViewController;
[theSegue setValue:@"这是要传递的值" forKey:@"strTitle"];
}
在下一个文件中接收要传递的信息;