简单的几个OC知识点
来源:互联网 发布:linux识别不到hba卡 编辑:程序博客网 时间:2024/05/02 17:49
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知识点
- OC的几个知识点总结
- OC中的几个基础知识点
- 几个简单的jquery知识点练习
- OC简单常用知识点归纳
- Silverlight的几个知识点
- JAVA的几个知识点
- Silverlight的几个知识点
- activity的几个知识点
- C++的几个知识点
- 几个Android的知识点
- WebService的几个知识点
- C#的几个知识点
- transform的几个知识点
- 【OC加强】SEL数据类型的简单知识点——和方法有关
- OC加强】SEL数据类型的简单知识点——和方法有关
- 收录java的几个知识点
- 关于jfreechart的几个知识点
- 大型项目开发:谨慎使用智能指针
- 微生物增殖
- 《Learn More,Study Less》读书笔记之自我反思
- 184Sum
- 快速排序
- 简单的几个OC知识点
- Chromium多线程模型设计和实现分析
- 报时助手
- Remove Specified Characters
- 工厂设计模式
- monkeyrunner截图限时免费阅读#1
- [NOI2014]魔法森林(动态加边+SPFA)
- 排序
- 解决Get和Post请求中中文乱码问题 (2013-01-26 23:59:39)转载▼ 标签: javaee it分类: JavaEE 对于Post请求,只需在Servlet或者jsp中写入如下