what is this weird code notation mean

前端 未结 3 825
迷失自我
迷失自我 2021-01-29 02:27

what\'s this line mean when using the second NSDictionay beside the message body:

NSDictionary *item = (NSDictionary *) [self.content objectAtIndex:indexPath.row];

3条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-29 02:31

    This is a cast, as in C.

    In your case, "self.content" seems to be an NSArray. So [self.content objectAtIndex:indexPath.row] would be an NSObject. Except that here, for some reason, you know it's an NSDictionary. So you explicitly cast it in order to avoid a compiler warning (that would tell you "hey, you're assigning an NSObject to an NSDictionary variable)

提交回复
热议问题