开发者

XCode - Compiler does not alert about a type-mismatch

开发者 https://www.devze.com 2023-02-04 18:08 出处:网络
Can you just tell me why this ...... compiler does not alert me about a possible type mismatch here ?

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 NS开发者_开发知识库String* to an NSHour*


Because the declaration says it returns id:

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

And id can easily be assigned to anything.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号