I get the warning Enumeration value 'SHKShareTypeUndefined' not handled in switch in the below code. I bolded the relevant line and pointer:
+ (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];
}
This warning is in ShareKit and I am not sure how to fix it.
Thanks!
Add dummy case for that enum value:
case SHKShareTypeUndefined:
break;
Or set your "Check switch statements" flag to NO in your target settings (warnings section)
You can also use a default
case:
switch (type) {
case SHKShareTypeURL:
favoriteSharers = ...
break;
// ...
default:
NSLog(@"Unexpected case - will do nothing here");
break;
}
If you have reason to want neither to add cases for all values of the enum nor to add a default case, and if you're compiling with clang, you can write
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wswitch"
switch (type) {
//...
}
#pragma clang diagnostic pop
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With