【发布时间】:2016-10-16 21:47:57
【问题描述】:
我有一个代码来创建我自己的函数,但它给了我一个警告:
- 从“int”分配给“SMUserKey *”(又名“unsigned long *”)的指针转换不兼容的整数
- 不兼容的整数到指针转换将“SMUserKey”(又名“unsigned long”)发送到“SMUserKey *”(又名“unsigned long *”)类型的参数
所以它显示警告,我想摆脱它们。
这是我的 .h 代码:
typedef NSUInteger SMUserKey;
NS_ENUM(SMUserKey) {
SMUsername = 1,
SMFirstName = 2,
SMLastName = 3,
SMFullName = 4,
SMEmail = 5,
};
这是我的 .m 代码:
-(void)awakeFromNib {
NSString *result = [SMUser getValueForKey:SMUsername];
NSLog(@"THE RESULT: %@", result);
}
+ (NSString *)getValueForKey:(SMUserKey*)myUserKey {
NSString *myUserKeyValue = nil;
if (myUserKey == 1) {
myUserKeyValue = @"Username";
}
if (myUserKey == 2) {
myUserKeyValue = @"First Name";
}
if (myUserKey == 3) {
myUserKeyValue = @"Last Name";
}
if (myUserKey == 4) {
myUserKeyValue = @"Full Name";
}
if (myUserKey == 5) {
myUserKeyValue = @"Email";
}
return myUserKeyValue;
}
这是显示警告的图片:
【问题讨论】:
标签: c++ ios objective-c macos function