// MyClass.h
@interface MyClass : NSObject
{
NSDictionary *dictobj;
}
@end
//MyClass.m
@implementation MyClass
-(void)applicationDiDFinishlaunching:(UIApplication *)application
{
}
-(void)methodA
{
// Here i need to add objects into the dictionary
}
-(void)methodB
{
//here i need to retrive the key and objects of Dictionary into array
}
我的问题是因为 methodA 和 methodB 都使用 NSDictionary 对象 [即 dictobj] 我应该在哪个方法中编写此代码:
dictobj = [[NSDictionary alloc]init];
我不能在这两种方法中做两次,因此如何做呢?