1. 属性传值:从前日后sql
2. 代理传值:从后往前数据库
3. block:spa
4. 单例:普通写法和GCD写法代理
5 . 通知 NSNotificationcode
GCD 单例:sqlite
static PlayMusicHelp *share = nil; + (PlayMusicHelp *)shareData { if (share == nil) { static dispatch_once_t haha; dispatch_once(&haha, ^{ share = [[PlayMusicHelp alloc] init]; }); } return share; }
1.blog
UIView 继承于UIResponder,继承
UIResponder继承于NSObject ,事件
UIView能够响应用户事件,string
CALayer用来绘制内容
2. storyboard:设置cell的自适应高度:
self.tableView.estimatedRowHeight = 44.0f;
self.tableView.rowHeight = UITableViewAutomaticDimension;
3. 本地已存在数据库文件 如何获取:
// 获取指定路径的数据库文件: NSString *document = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0]; NSString *filePath = [document stringByAppendingPathComponent:@"团购数据"]; NSString *savePath = [filePath stringByAppendingPathComponent:@"Display.sqlite"]; if ([[NSFileManager defaultManager]fileExistsAtPath:savePath]) { self.db = [FMDatabase databaseWithPath:savePath]; }
获取完以后,赋给self.db 而后就能够读取数据库里的数据了(经过self.db) 断网的状况下 也能够读取。
4. 将中文进行转码:
NSString *encodedValue2 = [str2 stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
5. 计算label高度:
// 计算文字高度 类方法 +(CGFloat)cellHeight:(NSString *)string { CGSize size = CGSizeMake(220, 1000); NSDictionary *dic = [NSDictionary dictionaryWithObject:[UIFont systemFontOfSize:17] forKey:NSFontAttributeName]; CGRect rect = [string boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin attributes:dic context:nil]; return rect.size.height; }
6. 指定路径下建立文件夹:
// 1. 建立存储数据的文件夹 :团购数据 NSString *document = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0]; NSLog(@"文件储存路径:%@", document); NSFileManager *manager = [NSFileManager defaultManager]; NSString *filePath = [document stringByAppendingPathComponent:@"团购数据"]; [manager createDirectoryAtPath:filePath withIntermediateDirectories:YES attributes:nil error:nil];