0

I have a question about the objective-C. I use the following code to add a contains from an array to another array. However, the second array is null. Can anyone help me? Thank you.

titleArray = [[csvDataArrayString objectAtIndex:0] componentsSeparatedByString:@","];

NSString *title;

dataTitleArray = [[NSMutableArray alloc] init];  // after add this statement it's ok

for(int i=0; i<[tTitleArray count]; i++)
{
    title = [csvPersonalTitleArray objectAtIndex:i];
    [dataTitleArray addObject:title];  // the dataTitleArray is null
}
3
  • If dataTitleArray is nil, then you'll need to expand your question to show where you're creating dataTitleArray and how it comes to be in the snippet you've quoted. Commented Aug 27, 2010 at 1:39
  • 1
    Or all these lines of code actually next to each other in this order, as written here, or are you picking and choosing from different parts of your program? I suspect the latter, and if so, there's no way we're going to find the bug from random snippets. Commented Aug 27, 2010 at 1:40
  • @Jarret Hardie, Chuck, thank you for your reply. It's solved Thank you. Commented Aug 27, 2010 at 1:46

1 Answer 1

1

You haven't shown that you're actually allocating dataTitleArray anywhere. Are you? It's not clear what you're trying to do.

Sign up to request clarification or add additional context in comments.

2 Comments

thank you for your reply. I edited the post. I just want to add an array to another array.
[oneArray addObjectsFromArray:anotherArray]

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.