1、NSDictionary、NSMutableDictionary
可以理解为java里面的map,一个key对应一个value,key不可以重复
NSDictionary不可变,NSMutableDictionary可变
NSMutableDictionary比NSDictionary多了一些增加,删除,修改的函数
比如setObject:forKey: removeObjectForKey:
2、测试Demo
NSDictionary+print.h
#import <Foundation/Foundation.h>
#ifndef NSDictionary_print_h
#define NSDictionary_print_h
@interface NSDictionary (print)
-(void)print;
@end
#endif /* NSDictionary_print_h */
NSDictionary+print.m
#import <Foundation/Foundation.h>
#import "NSDictionary+print.h"
@implementation NSDictionary(print)
-(void)print
{
NSMutableString *result = [NSMutableString stringWithFormat:@"{"];
for (id key in self)
{
[result appendString:[key description]];
[result appendString:@"="];
[result appendString:[self[key] description]];
[result appendString:@", "];
}
[result appendString:@"}"];
NSLog(@"%@", result);
}
@end
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交