nsmutablearray - Store user input in array objective-c -
i trying input user , want store in array.
int main(int argc, const char * argv[]) { @autoreleasepool { int i; char name[10]; nsmutablearray *myarray=[[nsmutablearray alloc]init]; (i=0; i<10; i++) { scanf("%c",name); [myarray addobject:i]; } } return 0; }
you trying insert non object in nsmutablearray.
nsmutablearray
can store objects only,
char
, int
data types of c
language not treated objects in objective c.
first need convert them objects can insert.
try this:
[myarray addobject:@(i)]; or [myarray addobject:[nsnumber numberwithint:i]]; name: [nsstring stringwithformat:@"%c",name]
Comments
Post a Comment