分割字符串:NSArray *tempArr = [fileName componentsSeparatedByString:@"."];
//颜色 UIColor *backgroundColor=[UIColor redColor]; //字体 UIFont *font=[UIFont boldSystemFontOfSize:18.0]; NSDictionary *attrsDic=@{ NSForegroundColorAttributeName:backgroundColor, NSFontAttributeName:font }; self.mySearchBar.attributedPlaceholder = [[NSAttributedString alloc]initWithString:@"请输入展品编号" attributes:attrsDic];
#pragma mark - 更新主页面操作 dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0),^{ //耗时的操作 dispatch_async(dispatch_get_main_queue(),^{ //更新界面 }); }); #pragma mark - 顺序执行// dispatch_queue_t aqueue = dispatch_queue_create("sdfs",DISPATCH_QUEUE_CONCURRENT);// dispatch_barrier_async(aqueue, ^{NSLog(@"1111");});// dispatch_barrier_async(aqueue, ^{NSLog(@"2222");});// dispatch_barrier_async(aqueue, ^{NSLog(@"3333");}); #pragma mrak - 随机执行// dispatch_queue_t aqueue = dispatch_queue_create("sdfs",DISPATCH_QUEUE_CONCURRENT);// dispatch_async(aqueue, ^{// NSLog(@"111");// });// dispatch_async(aqueue, ^{// NSLog(@"222");// });// dispatch_async(aqueue, ^{// NSLog(@"666");// });// dispatch_async(aqueue, ^{// NSLog(@"999");// }); #pragma mark - 队列执行// dispatch_queue_t aqueue = dispatch_queue_create("sdfs",DISPATCH_QUEUE_CONCURRENT);// dispatch_group_t group = dispatch_group_create();// dispatch_group_async(group,aqueue, ^{// NSLog(@"1111");// [NSThread sleepForTimeInterval:1.0];// });// dispatch_group_async(group,aqueue, ^{// NSLog(@"2222");// [NSThread sleepForTimeInterval:2.0];// });// dispatch_group_async(group,aqueue, ^{// NSLog(@"3333");// [NSThread sleepForTimeInterval:3.0];// });// // dispatch_group_notify(group, aqueue, ^{// NSLog(@"finish");// });
@property(strong,nonatomic)UIRefreshControl *refresh;[self.refresh beginRefreshing];//viewWillAppear [self refreshAction:nil];self.refresh = [[UIRefreshControl alloc]init];//viewDidLoad [self.refresh addTarget:self action:@selector(refreshAction:) forControlEvents:UIControlEventValueChanged]; self.refresh.attributedTitle = [[NSAttributedString alloc]initWithString:@"下拉刷新"]; [self.myTableView addSubview:self.refresh];#pragma mark - refreshMethods-(void)refreshAction:(NSString*)str{ [self.refresh performSelector:@selector(endRefreshing) withObject:nil afterDelay:2.0]; [self.myTableView reloadData];}
NSString *resourcePath = [NSString stringWithFormat:@"%@/Resource",[declare applicationLibraryDirectory]]; if (![[NSFileManager defaultManager]fileExistsAtPath:resourcePath]) { [[NSFileManager defaultManager] createDirectoryAtPath:resourcePath withIntermediateDirectories:NO attributes:nil error:nil]; }
@property (nonatomic, strong) NSArray *dataArray;
#pragma mark - tableView delegate#define Row_Height 100- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ return Row_Height;}- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return self.dataArray.count;}- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ static NSString *cellName = @"cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellName]; if (!cell) { cell = [[UITableViewCell alloc]init]; // cell.selectionStyle = UITableViewCellSelectionStyleNone; } return cell;}- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ }
//筛选信息 NSArray *arr = [[NSArray alloc]initWithObjects:@"beijing",@"shanghai",@"tianjin",@"shenzhen", nil]; NSString *string = @"in"; NSPredicate *pred = [NSPredicate predicateWithFormat:@"SELF CONTAINS %@",string]; NSLog(@"%@",[arr filteredArrayUsingPredicate:pred]);//提取字符串中的字母或数字 NSString *originalString = @"daxf1bw2cq3d45f6ge7h8i9j0"; // Intermediate NSMutableString *numberString = [[NSMutableString alloc] init]; NSString *tempStr; NSScanner *scanner = [NSScanner scannerWithString:originalString]; NSCharacterSet *numbers = [NSCharacterSet characterSetWithCharactersInString:@"qwe"]; while (![scanner isAtEnd]) { // Throw away characters before the first number. [scanner scanUpToCharactersFromSet:numbers intoString:NULL]; // Collect numbers. BOOL isSccess = [scanner scanCharactersFromSet:numbers intoString:&tempStr];; [numberString appendString:tempStr]; tempStr = @""; NSLog(@"tempStr:%@ numberString:%@ bool:%d",tempStr,numberString,isSccess); }//导航条按钮UIButton *rightBtn = [UIButton buttonWithType:UIButtonTypeCustom]; rightBtn.backgroundColor = [UIColor clearColor]; rightBtn.frame = CGRectMake(0, 0, 40, 40); [rightBtn setImage:[UIImage imageNamed:@"button5"] forState:UIControlStateNormal]; [rightBtn setImage:[UIImage imageNamed:@"button5_pressed"] forState:UIControlStateHighlighted]; [rightBtn addTarget:self action:@selector(rightBtnClick:) forControlEvents:UIControlEventTouchUpInside]; UIBarButtonItem *barBtn = [[UIBarButtonItem alloc]initWithCustomView:rightBtn]; self.navigationItem.rightBarButtonItem = barBtn; UIBarButtonItem *nItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:self action:nil]; self.navigationItem.leftBarButtonItem = nItem;//宏定义 变量字符串化#define WARN_IF(EXP) \do { if (EXP) \ fprintf( stderr,"Warning " #EXP "\n" ); \} while(0) int x = 0; WARN_IF(x == 0);//cookiesNSHTTPCookieStorage *pool = [NSHTTPCookieStorage sharedHTTPCookieStorage];NSArray *cookies = [pool cookies];for (NSHTTPCookie *cookie in cookies ) { [pool deleteCookie:cookie];}isFinite( number ) 函数用于检查其参数是否是无穷大。如果 number 是有限数字(或可转换为有限数字),那么返回 true。否则,如果 number 是 NaN(非数字),或者是正、负无穷大的数,则返回 false学习了FMDB三方库的使用,对sqlite进行操作时 表名、参数名不用带单引号 值必须带单引号 如:@"UPDATE %@ SET %@ = '%@' WHERE %@ = '%@'", TABLENAME, AGE, @"15", AGE, @"12”//修改数据
segue跳转:
[self performSegueWithIdentifier:@"goToRootView" sender:nil];
添加tableViewcell编辑操作。//-(UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath//{ // return UITableViewCellEditingStyleDelete;//}////- (void)tableView:(UITableView*)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath*)indexPath {// if (editingStyle == UITableViewCellEditingStyleDelete) {// // //[self.da removeObjectAtIndex:indexPath.row];// [self.myTableView deleteRowsAtIndexPaths:@[indexPath]// withRowAnimation:UITableViewRowAnimationAutomatic];// [self.myTableView reloadData];// }//}////-(BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath//{// return YES;//}
// [self.myTableView beginUpdates];
// NSArray *indexPaths = @[indexPath];
// [self.myTableView deleteRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationLeft];
// [self.myTableView endUpdates];