这是NSObject类
FileHandler.h
@interface fileHandler : NSObject
@property(nonatomic,strong) NSMutableArray *arrCategoryList;
@property(nonatomic,strong) NSMutableDictionary *dicCategoryList;
@property(nonatomic,strong) NSMutableDictionary *dicAllSubCategoryList;
@property(nonatomic,strong) NSMutableDictionary *dicProductList;
+(fileHandler *)getDataHandler;
-(void)categoryStorage:(NSMutableArray *)arrCategory :(NSMutableDictionary *)dicCategory :(NSMutableDictionary *)dicSubCategory;
-(void)addCategoryList:(NSMutableDictionary *)holeArray;
-(void)addSubCategories:(NSMutableDictionary *)dictCategory;
-(void)releaseData;
@end
这是NSObject Class .m
FileHandler.m
static fileHandler *internalInstance=Nil;
static dispatch_once_t internalOnceToken=0;
@implementation fileHandler
-(id)init
{
self=[super init];
[self allocateMemory];
return self;
}
+(fileHandler *)getDataHandler
{
dispatch_once(&internalOnceToken,^{
internalInstance = [[fileHandler alloc] init];
if(internalInstance) {
NSLog(@"Internal instance created: %@", internalInstance);
}
});
if(internalOnceToken == -1) {
NSLog(@"Internal instance exists: %@", internalInstance);
}
return internalInstance;
}
-(void)allocateMemory
{ NSLog(@"incoming");
self.arrCategoryList=[[NSMutableArray alloc]init];
self.dicCategoryList=[[NSMutableDictionary alloc]init];
self.dicAllSubCategoryList=[[NSMutableDictionary alloc]init];
self.dicProductList=[[NSMutableDictionary alloc]init];
}
-(void)categoryStorage:(NSMutableArray *)arrCategory :(NSMutableDictionary *)dicCategory :(NSMutableDictionary *)dicSubCategory
{
self.arrCategoryList=arrCategory;
NSLog(@"arrcatewelcome%@",self.arrCategoryList);
self.dicCategoryList=dicCategory;
self.dicAllSubCategoryList=dicSubCategory;
NSLog(@"welcome%@",arrCategory);
NSLog(@"%@",dicCategory);
NSLog(@"%@",dicSubCategory);
}
-(void)addCategoryList:(NSMutableDictionary *)holeArray
{
self.dicCategoryList=holeArray;
NSLog(@"insidehandler");
}
-(void)addSubCategories:(NSMutableDictionary *)dictCategory
{
self.dicAllSubCategoryList=dictCategory;
}
-(void)releaseData
{
self.arrCategoryList=nil;
self.dicAllSubCategoryList=nil;
self.dicProductList=nil;
self.dicCategoryList=nil;
}
@end
这是另一个类,我在NSObject类中提到了数组和字典的值。
collectionAntZ.m
-(void)responseFunction:(NSMutableDictionary *)response
{
BOOL sucess;
sucess =[[response objectForKey:@"sucess"]boolValue];
NSLog(@"response Method%@",response);
NSLog(@"%hhd",sucess);
NSString *subimages;
if(!sucess)
{
ArrCategory =[response objectForKey:@"category"];
for(NSDictionary *DicHoleCategories in ArrCategory)
{
NSMutableDictionary *DicAllValues=[[NSMutableDictionary alloc]init];
[DicAllValues setObject:[[DicHoleCategories objectForKey:@"name"] length] !=0?[DicHoleCategories objectForKey:@"name"] :@"" forKey:@"name"];
[DicAllValues setObject:[DicHoleCategories objectForKey:@"category_id"] forKey:@"category"];
StrName=[DicHoleCategories objectForKey:@"image"];
[DicAllValues setObject:[DicHoleCategories objectForKey:@"subcategory"] forKey:@"subcategory"];
if(StrName!=nil)
{
subimages=[NSString stringWithFormat:LocalImage"%@",StrName];
[DicAllValues setObject:subimages forKey:@"image"];
[arrImages addObject:[DicAllValues objectForKey:@"image"]];
}
[ArrName addObject:DicAllValues];
[dicAllValues setObject:DicAllValues forKey:@"hole"];
}
arrSubCategory=[ArrName valueForKey:@"subcategory"];
[dicSubCategory setObject:[arrSubCategory valueForKey:@"parent_id"] forKey:@"parent"];
[dicSubCategory setObject:[arrSubCategory valueForKey:@"image"] forKey:@"image"];
[dicSubCategory setObject:[arrSubCategory valueForKey:@"name"] forKey:@"name"];
NSLog(@"array of sub category%@",dicSubCategory);
**[file categoryStorage:ArrCategory :dicAllValues:dicSubCategory];
[file addCategoryList:dicSubCategory];**
尝试访问.m文件中的另一个类
@property(nonatomic ,retain)fileHandler *handler;
@end
@implementation orderVC
- (void)viewDidLoad {
[super viewDidLoad];
#pragma mark file handle
NSLog(@"orderarray%@",self.handler.arrCategoryList);
NSLog(@"dictionary objects %@",self.handler.dicAllSubCategoryList);
在这里,我发布我的问题请任何人解释为什么我没有在另一个类中访问NSobject类值。