Question

I want to create a UIActionSheet but I always get a warning about a "missing sentinel":

/Users/....mm:136:173: warning: missing sentinel in method dispatch [-Wsentinel]

UIActionSheet* adsl_action_sheet = [[[UIActionSheet alloc] initWithTitle:nil 
                                                                delegate:(id<UIActionSheetDelegate>)self 
                                                       cancelButtonTitle:[dsd_string_localizer ms_get_localized_system_string:@"Cancel"] 
                                                  destructiveButtonTitle:nil 
                                                       otherButtonTitles:[dsd_string_localizer ms_get_localized_system_string:@"Logoff"], [dsd_string_localizer ms_get_localized_system_string:@"Disconnect"], nil] autorelease];

I really can't see anything wrong... maybe I'm just blind.

The file containing this code is an Objective-C++ file.

I also noticed that it is showing these "Sentinel Warnings" at every place which needs such a sentinel.

Was it helpful?

Solution

You need to cast that final "sentinel" nil to the correct type, using:

... , (NSString *)nil] autorelease];
//    ^^^^^^^^^^^^

However, I am not certain why the compiler requires this cast.

I believe this is necessary when compiling with -Wstrict-null-sentinel (waiting for confirmation from OP).

OTHER TIPS

From the compiler output i believe that you are not putting a nil correctly at the end of the variadic method call.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top