简单的几个OC知识点
2016-12-19 17:25
295 查看
1.关于系统自定义设值取值方法的理解
oc在接口文件里面使用@property int a;
在实现文件里面使用
@synthesize int a;
来实现系统自动的设值取值函数,个人对这两句话暂时的理解是@property相当于将方法进行了声明
2.关于oc中访问方式
oc中的实例变量都是private,而方法都是public的,所以访问实例变量(就是类中定义的变量然后实例化以后才能使用的变量)的时候需要自己写设值取值函数。3.本地推送消息无权限的问题
haven’t received permission from user貌似是ios8改了以后的问题,可以在appDelegate.m文件中加入如下代码
if ([UIApplication instancesRespondToSelector:@selector(registerUserNotificationSettings:)]){ [application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert|UIUserNotificationTypeBadge|UIUserNotificationTypeSound categories:nil]]; } else { [application registerForRemoteNotificationTypes:UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge]; }
4. 如何将tableView设置为多个section
比如一个数组{1,5,4,6,7,3} 按照相应的顺序将大于5的放前面,小于等于5的放后面预处理:
将数组改装成{{6,7},{1,5,4,3}},并将NSMutableArray* multitem[0]={6,7},NSMutableArray* multitem[1]={1,5,4,3};
然后
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ return 2; } -(NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section{ // return [[[BNRItemStore sharedStore] allItems]count]; return [multitem[section] count]; } -(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ UITableViewCell* cell=[tableView dequeueReusableCellWithIdentifier:@"UITableViewCell" forIndexPath:indexPath]; // NSArray* items=[[BNRItemStore sharedStore] allItems]; BNRItem* item=multitem[indexPath.section][indexPath.row]; cell.textLabel.text=[item description]; return cell; }
5.weak指针是不能作为变量的拥有者的
所以不存在(_weak) UIView* view=[UIView alloc]init];
这样初始化为导致view无值,因为初始化了一个UIView,但是并没有strong指针指向相应的内存位置,从而会导致无拥有着而释放,从而view因为是弱指针且无指向从而释放。
6.ios8之后系统使用CLLocation定位没反应
这个需要进行一项配置,在plist中加入NSLocationWhenInUseUsageDescription Boolean YES
然后在程序中调用
[self.locationManager requestWhenInUseAuthorization]; [self.locationManager startUpdatingLocation];
就可以在程序使用期间调用CLLocation框架进行定位了,如果需要始终定位,在plist中加入
NSLocationAlwaysUsageDescription Boolean YES
在程序中调用
[self.locationManager requestAlwaysAuthorization] [self.locationManager startUpdatingLocation];
相关文章推荐
- 【OC加强】SEL数据类型的简单知识点——和方法有关
- OC简单常用知识点归纳
- OC的几个知识点总结
- OC加强】SEL数据类型的简单知识点——和方法有关
- 几个简单的jquery知识点练习
- Java几个技术点,简单的说说学好Java必须弄懂哪些知识点
- JavaScript 写几个简单的知识点
- 【OC加强】OC编程语言强化知识点简单归纳——理解OC提升能力之用
- JavaScript 写几个简单的知识点
- 几个小知识点
- 几个简单的正则表达式
- 几个简单的mysql命令就可以解决的问题
- 几个简单的代码优化技术(二)
- 保证数据库安全的几个简单步骤
- 日语学习笔记(一) 动词、形容词、形容动词的几个简单变化
- 几个小知识点
- CPPWebBrowser的几个简单应用
- Schema的几个简单例子 入门
- 几个简单的代码优化技术(一)
- 如何学习数据库??《part1。几个简单的提问》