Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/43.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 将对象添加到不同类中的NSMutableArray_Iphone_Objective C_Class_Object_Nsmutablearray - Fatal编程技术网

Iphone 将对象添加到不同类中的NSMutableArray

Iphone 将对象添加到不同类中的NSMutableArray,iphone,objective-c,class,object,nsmutablearray,Iphone,Objective C,Class,Object,Nsmutablearray,我有一个类SplitMonths和January,使用这个类SplitMonths,我尝试在类January中的NSMutableArray中存储对象,但是我似乎无法让它工作 六个月 @class January; @interface ... { NSMutableArray * calEvents; January *janClass; } -(void)separate; @property (nonatomic, assign) January *janClass; 好几

我有一个类SplitMonths和January,使用这个类SplitMonths,我尝试在类January中的NSMutableArray中存储对象,但是我似乎无法让它工作

六个月

@class January;
@interface ... {
NSMutableArray * calEvents;

January *janClass;      
}
-(void)separate;
@property (nonatomic, assign) January *janClass;
好几个月了

#import "January.h"
@implementation SplitMonths
@synthesize janClass;
-(void)viewDidLoad{
    [super viewDidLoad];
    janClass = [[January alloc]initWithNibName:@"January" bundle:nil];
    janClass.JanEvents = [[NSMutableArray alloc]init];
    n=0;

} 
....REST OF CODE...Loading stuff into calEvents.

-(void)separate{
    int incrS = 0;
    while (incrS < [calEvents count]){
        if ([monthString rangeOfString:@"Jan"].location == NSNotFound){
        }else{
            [[janClass JanEvents] addObject:[calEvents objectAtIndex:incrS]];
            NSLog(@"STORY ADDED");
        }
        NSLog(@"ARRAY:%@",janClass.JanEvents);
        incrS = incrS + 1;
    }
    [janClass.JanEvents release];
    NSLog(@"COUNT:%d",[janClass.JanEvents count]);

}
一月

@synthesize JanEvents;

Add I checked和calEvents确实包含包含@“Jan”的对象,我使用断点测试过,它们不会添加到nsmutablearray。

您有几个内存管理问题。但首先,您是否在日志中看到“添加的故事”?您可以显示日志输出吗?2011-12-24 13:24:10.628[1377:15803]添加的故事2011-12-24 13:24:12.358[1377:15803]MONTHSTRING:(null)此MONTHSTRING日志行在代码中的何处?数组:line发生了什么?我不小心重命名了它,MONTHSTRING是数组,所以数组是(null)
@synthesize JanEvents;