objective-c的NSDictionary, 为什么这段输出是null
NSDictionary*dict=[NSDictionarydictionaryWithObjectsAndKeys:@"jack",@"jackisaboy",@"j...
NSDictionary * dict = [NSDictionary dictionaryWithObjectsAndKeys:
@"jack", @"jack is a boy",
@"john", @"john is a boy",
@"lisa", @"lisa is a girl",
nil];
NSString * str = [dict objectForKey:@"john"];
NSLog(@"%@", str); 展开
@"jack", @"jack is a boy",
@"john", @"john is a boy",
@"lisa", @"lisa is a girl",
nil];
NSString * str = [dict objectForKey:@"john"];
NSLog(@"%@", str); 展开
2个回答
展开全部
NSDictionary * dict = [NSDictionary dictionaryWithObjectsAndKeys:
@"jack is a boy", @"jack",
@"john is a boy", @"john",
@"lisa is a girl", @"lisal",
nil];
NSString * str = [dict valueForKey:@"john"];
NSLog(@"%@", str);
//这样就能行,因为左边是value,右边是key
objectForKey 是通过key 找object
@"jack is a boy", @"jack",
@"john is a boy", @"john",
@"lisa is a girl", @"lisal",
nil];
NSString * str = [dict valueForKey:@"john"];
NSLog(@"%@", str);
//这样就能行,因为左边是value,右边是key
objectForKey 是通过key 找object
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询