[2014-09-25]对于Xcode6里面反射(p…
来源:互联网 发布:淘宝的港货可以买吗? 编辑:程序博客网 时间:2024/04/30 15:28
我在项目中用到了sqlite,使用的是mvc模式,所以就直接把model存入数据库,就使用到了property_getName方法,来获取model里面的属性。在xcode5里面能够获取正确的属性,但是在xcode6里面就会多出以上4个属性。于是我的解决方法就在遍历是,遇到以上4个属性就continue,代码如下:(如有不对,请大家指出)。
unsigned int outCount, i;
objc_property_t *properties =class_copyPropertyList([selfclass], &outCount);
for (i = 0; i < outCount; i ++){
objc_property_t property = properties[i];
NSString *propertyName =[NSStringstringWithCString:property_getName(property)encoding:NSUTF8StringEncoding];
if ([propertyNameisEqualToString:@"primaryKey"] ||[propertyNameisEqualToString:@"rowid"]
|| [propertyNameisEqualToString:@"hash"]|| [propertyNameisEqualToString:@"superclass"]||[propertyNameisEqualToString:@"description"] ||[propertyNameisEqualToString:@"debugDescription"]){
continue;
}
[pronames addObject:propertyName];
NSString *propertyType =[NSStringstringWithCString:property_getAttributes(property)encoding:NSUTF8StringEncoding];
if ([propertyTypehasPrefix:@"T@"]) {
[protypes addObject:[propertyTypesubstringWithRange:NSMakeRange(3,[propertyTyperangeOfString:@","].location- 4)]];
}
else if ([propertyTypehasPrefix:@"Ti"])
{
[protypes addObject:@"int"];
}
else if ([propertyTypehasPrefix:@"TF"])
{
[protypes addObject:@"float"];
}
else if([propertyTypehasPrefix:@"Td"]) {
[protypes addObject:@"double"];
}
else if([propertyTypehasPrefix:@"Tl"])
{
[protypes addObject:@"long"];
}
else if ([propertyTypehasPrefix:@"Tc"]) {
[protypes addObject:@"char"];
}
else if([propertyTypehasPrefix:@"Ts"])
{
[protypes addObject:@"short"];
}
}
free(properties);
- [2014-09-25]对于Xcode6里面反射(p…
- 对于Xcode6里面反射(property_getName)问题。
- [2014-10-09]Xcode6更新之后的一些…
- 对于mkdir -p 的理解
- 反射里面的错误.
- 在xcode6中使用矢量图(iPhone6/6P 适配UI)
- 对于已排序p[]枚举p的所有子集
- 对于java反射的理解
- 对于python的反射机制
- 对于摄像机而言同样清晰度下25p和50i画质会有什么差别?
- 对于刚接触iOS开发,Xcode6的部分疑惑
- xcode6 里面通过subclass UITabbar 来修改tabbar的高度
- 使用Xcode6.0模拟器不能在textField里面输入中文
- 判断点P是否在多边形里面
- p里面的字自动换行
- xcode6
- xcode6
- 对于(function(){}())和function(){}实例的作用域分析(里面有很多问题……)
- [2014-04-20]ios获取数据中去掉htm…
- [2014-04-21]解决uitableviewcell…
- iOS 开发者必知的 75&nb…
- ios支付宝Demo报错(Linker co…
- [2014-06-01][转]apps须遵循iOS数…
- [2014-09-25]对于Xcode6里面反射(p…
- [2014-10-09]Xcode6更新之后的一些…
- [2014-10-20]XCode6编译问题:fata…
- XCode报错 has been&nbs…
- [转]UISearchbar去除背景色的方法…
- [2014-10-18]iOS8开发错误整理(持…
- 程序员应该关注的一些事儿
- [2014-11-25]友盟分享错误汇总
- Ubuntu下Python建立和连接数据库