Oliver
Oliver

Reputation: 23500

Xcode - Compiler does not alert about a type-mismatch

Why this compiler does not alert me about a possible type mismatch here?

NSHour* H1; // My object

if (H1 == nil) doSomething
else H1 = [NSString stringWithFormat:@"%@%@", H1, @":00"];  --- Here : affecting an NSString* to an NSHour*

Upvotes: 0

Views: 348

Answers (1)

Eiko
Eiko

Reputation: 25632

Because the declaration says it returns id:

+ (id)stringWithFormat:(NSString *)format, ...

And id can easily be assigned to anything.

Upvotes: 1

Related Questions