Hello! First post ever on this forum.
However, i have some big problems in my app development. I'm coming from C++, but I'm now trying to get the hang of Objective-c.
So my problem is:
I'm trying to make kind of an statictics(i'm aware of the wrong spelling) multiview app. I've managed to get the different views working, but thats not really the problem.
In a seperate header(and m) file, i have my class. like this;
I've instanced a global variabel (i know its bad) like:
So in one view, i want to take input from the user, and add an Object of MyClass to myArray. Like: (the short version)
So far, so good i hope.
Now i'm trying to print all this shizz out in another view (in a textview)
This last method causes bad access about every time, sometimes it workes if it is only 1 object in myArray.
I know its like tons of errors here. Please help!!
However, i have some big problems in my app development. I'm coming from C++, but I'm now trying to get the hang of Objective-c.
So my problem is:
I'm trying to make kind of an statictics(i'm aware of the wrong spelling) multiview app. I've managed to get the different views working, but thats not really the problem.
In a seperate header(and m) file, i have my class. like this;
Code:
@interface MyClass : NSObject
{
NSString *name;
int someValue;
}
I've instanced a global variabel (i know its bad) like:
Code:
NSMutablearray *myArray;
So in one view, i want to take input from the user, and add an Object of MyClass to myArray. Like: (the short version)
Code:
-(IBAction) someMethod:(id)sender {
MyClass *p=[[MyClass alloc]init];
[p setName:self.'someTextField'.text]; (ofcourse without the " ' " )
[myArray addObject : p];
'someTextField'.text=nil;
[p release];
}
So far, so good i hope.
Now i'm trying to print all this shizz out in another view (in a textview)
Code:
-(IBAction) someMethod2: (id)sender{
int size=[gListe count];
someTextView.text=nil;
NSMutableString *aString =[[NSMutableString alloc]init];
if (size>0) {
for (int i=0 ; i<size ; i++) {
[aString appendString: [myArray objectAtIndex:i].name];
[aString appendString: @"\n"];
}
someTextView.text=aString;
[aString release];
}
}
This last method causes bad access about every time, sometimes it workes if it is only 1 object in myArray.
I know its like tons of errors here. Please help!!
Last edited: