0

hi i am new iphone programmer i want to know that can we create array of integer,array of strings....etc seperatly like c++ if yes then how.... i have read about the example given on this site but that is c style of array.... please reply

2 Answers 2

2

NSArray is the standard array class in Cocoa/Cocoa Touch. It can contain objects, but not primitives.

You can store integers in an array by wrapping them with an NSNumber object like so:

NSNumber *myInt = [NSNumber numberWithInt:1];

Then you can store it in an array like so:

NSArray *myArray = [NSArray arrayWithObject:myInt];
Sign up to request clarification or add additional context in comments.

1 Comment

i tried this one but problem is that i want to store man values in it but it does not supporting
1
NSArray *arr = [NSArray arrayWithObjects:@"a", @"b", @"c", nil];

NSArray *arr = [NSArray arrayWithObjects:[NSNumber numberWithInteger:1]
                                       , [NSNumber numberWithInteger:2]
                                       , [NSNumber numberWithInteger:3]
                                       , nil];

Here's a reference.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.