i have a problem, i have this classes:
MainViewController.m
MainViewController.h
Myapp.m
Myapp.h
i want use a method "restanswer" declared in Myapp.m in MainViewController.m, this is the code:
//MyApp.h @class MainViewController;
@interface MyApp : DEFINE_SUPERCLASS // << @todo note to OP: define your superclass. you rarely need to create a root class in objc.
{
NSMutableArray * answer;
}
@property (nonatomic, retain) NSMutableArray *answer;
- (NSMutableArray *) restarray;
@end
//MyApp.m
#import "MainViewController.h"
@implementation Myapp
@synthesize answer;
NSMutableArray * answer = nil;
- (NSMutableArray *)restarray {
answer = [[NSMutableArray alloc] initWithObjects:@"1", @"2",@"3", nil];
return answer;
}
//MainViewController.m
#import "MyApp.h"
@implementation MainViewController
@synthesize answer;
static Myapp * risposte;
-(void).......{
NSMutableArray * prova = [risposte restarray];
int numbertest = [prova count];
NSLog(@"the value is: %d", numbertest);
}
i have no error, but the value of numbertest is: 0, why? my array have 3 object, please help me...sorry for format code i try but don't work...
NSMutableArray * answer = nil;probably does not do what you think it does. it declares a newanswer, and has nothing to do with the instance variableanswer