ΩlostA
ΩlostA

Reputation: 2601

iOS: Warning message "Format specifies type 'int' but the argument has type 'char *(*)(const char *, int)'"

I have an error message on the 2nd NSLog for the %c:

for info, here is the type of 'index' char => *index(const char *, int) __POSIX_C_DEPRECATED(200112L);

I don't understand what type I have to put here:

@try {
     [[cellToFill valueForKey:@"_textField"] setAutocapitalizationType: [[color valueForKey:@"textField.autocapitalizationType"] integerValue]];
}
@catch (NSException *exception) {
    NSLog(@"%@", exception.reason);
}
@finally {
    NSLog(@"Char at index %c cannot be found", index); 
}

What is the good type to put in the NSLog to avoid that warning?

Upvotes: 0

Views: 417

Answers (2)

CRD
CRD

Reputation: 53010

You have probably written the wrong identifier, index, in your NSLog() call.

You code suggests you believe index is a character variable (e.g. declared as char index;) somewhere.

The error message states that index is of type char *(*)(const char *, int), that is: a pointer to a function which takes a character pointer and an integer value and returns a character pointer.

Now it just happens there is a standard C library function index() of exactly that type.

Conclusion: you have mistyped your variable name as index, or typed it where it is out of scape, and therefore are getting the C library function – if you just write a function name in (Objective-)C you get a value which is a pointer to the function, exactly as your error message describes.

Upvotes: 1

Kerberos
Kerberos

Reputation: 4166

Your char * is not a character but it is a pointer to a string, you can try changing the %c to %s.

If you use a standard char you can log it with a %c.

Upvotes: 0

Related Questions