0

This is what I have

NSMutableArray Code = [COMM 112, MATH 101, SCI 201];
NSMutableArray Name = [Commerce, Calculas , Science];

NSMutableArray Course;
for(int i=0; i < [code count]; i++)
{
    [Course objectAtIndex:i] = [Code objectAtIndex:i] + "-" + [Name objectAtIndex:i];
}

What I want to end up with:

Course = [COMM 112 - Commerce, MATH 101 - Calculas, SCI 201 - Science];

This is just pseudo code! Any help to achieve this?

1 Answer 1

3
NSMutableArray * courseCodes = [@"COMM 112", @"MATH 101", @"SCI 201"];
NSMutableArray * courseNames = [@"Commerce", @"Calculus" , @"Science"];

// Check: if ([courseCodes count] != [courseNames count]) something went wrong...   

NSMutableArray * courseDescriptions = [NSMutableArray array];
for(int i = 0; i < [courseCodes count]; i++)
{
    NSString * courseDescription = [NSString stringWithFormat:@"%@ - %@",
                                    [courseCodes objectAtIndex:i],
                                    [courseNames objectAtIndex:i]];
    [courseDescriptions addObject:courseDescription];
}
Sign up to request clarification or add additional context in comments.

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.