【发布时间】:2011-04-20 19:29:03
【问题描述】:
我想完成类似这篇文章中所做的事情:Constants in Objective-C
但是,我想构建一个 NSDictionary。
如果我这样做:
常量.h
extern NSArray *const mFooKeys;
extern NSArray *const mFooObjects;
extern NSDictionary *const mFooDictionary;
常量.m
NSArray *const mFooKeys = [[NSArray alloc] initWithObjects:
@"Foo", @"Bar", @"Baz", nil];
NSArray *const mFooObjects = [[NSArray alloc] initWithObjects:
@"1", @"2", @"3", nil];
NSDictionary *const mFooDictionary = [[NSDictionary alloc] dictionaryWithObjects:mFooObjects
forKeys:mFooKeys];
我是否在 dealloc 中释放并且一切都很好,还是还有更多?这是一个比“有问题”的问题更谨慎的问题,但我觉得我真的可以在没有意识到的情况下把它搞砸。
【问题讨论】:
标签: objective-c release constants nsdictionary