我收到以下代码中未在开关中处理的警告枚举值'SHKShareTypeUndefined'。我加粗了相关的行和指针:
+ (NSArray *)favoriteSharersForType:(SHKShareType)type
{
NSArray *favoriteSharers = [[NSUserDefaults standardUserDefaults] objectForKey:[NSString stringWithFormat:@"%@%i", SHK_FAVS_PREFIX_KEY, type]];
// set defaults
if (favoriteSharers == nil)
{
switch (type)
{
case SHKShareTypeURL:
favoriteSharers = [NSArray arrayWithObjects:@"SHKTwitter",@"SHKFacebook",@"SHKReadItLater",nil];
break;
case SHKShareTypeImage:
favoriteSharers = [NSArray arrayWithObjects:@"SHKMail",@"SHKFacebook",@"SHKCopy",nil];
break;
case SHKShareTypeText:
favoriteSharers = [NSArray arrayWithObjects:@"SHKMail",@"SHKTwitter",@"SHKFacebook", nil];
break;
case SHKShareTypeFile:
favoriteSharers = [NSArray arrayWithObjects:@"SHKMail", nil];
break;
case SHKShareTypeUndefined:
break;
}
// Save defaults to prefs
[self setFavorites:favoriteSharers forType:type];
}
此警告位于ShareKit中,我不确定如何修复它。
谢谢!
最佳答案
为该枚举值添加虚拟大小写:
case SHKShareTypeUndefined:
break;
或在目标设置(警告部分)中将“检查开关语句”标志设置为“否”