문제

Can you just tell me 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*
도움이 되었습니까?

해결책

Because the declaration says it returns id:

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

And id can easily be assigned to anything.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top