【发布时间】:2013-11-14 08:38:22
【问题描述】:
我正在使用最新的 SDK 开发 iOS 5.0+ 应用程序。
我有这两种方法。
在UserPreferences 上课。
+ (User*)getUserFromUserPreferences;
在ProfileViewController 上课:
- (void)showUserData:(UserProfile*)userToShow;
还有一个继承自 User 的 UserProfile:
@interface UserProfile : User
@property (nonatomic, strong) NSNumber* isBlockedByMe;
@property (nonatomic, strong) NSNumber* isMyFriend;
@end
最后,我有这段代码,它给了我一个警告:
[self showUserData:[User getUserFromUserPreferences]];
带有消息:
Incompatible pointer types sending User* to parameter of type UserProfile*.
我这样做是否正确?
[self showUserData:(UserProfile*)[User getUserFromUserPreferences]];
或者,我可能会遇到内存泄漏或任何其他问题。
【问题讨论】:
标签: ios iphone objective-c