标签:mystra objective-c 容器 nsinteger
容器(NSMutableArray, NSMutableDictionary)的获取元素方法objectForKey:返回id类型,
转换NSInteger类型, 使用integerValue.
// newQuestion is an NSDictionary defined somewhere
NSInteger questionId = [[newQuestion objectForKey:@"question_id"] integerValue];
Just to be clear, the compiler won’t complain about sending any message to an id, instead if the object isn’t really an object (a struct or primitive), or doesn’t respond to that message, you’ll get an exception at runtime (not at build).
版权声明:本文为博主原创文章,未经博主允许不得转载。
标签:mystra objective-c 容器 nsinteger
原文地址:http://blog.csdn.net/caroline_wendy/article/details/46858963