Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1062693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:40:00+00:00 2026-05-16T18:40:00+00:00

I have a bunch of NSStrings in a NSMutableArray. I have added them to

  • 0

I have a bunch of NSStrings in a NSMutableArray. I have added them to the array and now I want to loop through the array, getting each object in it (the strings) and set them to a common value @”No Lessons”.

This is how I have the loop so far: But how can I get the object then set it? Currently its fairly simple, just getting looping through the array, not changing anything.

NSInteger *count = [monLessonArrayA count];
    for (int i = 0; i < count; i++) {
        [monLessonArrayA objectAtIndex:i];
    }

Any help much appreciated, thanks.

EDIT:

Turns out there is a larger issue somewhere. This is the code I am using:

NSMutableArray* lessonArrayFuncTwo(id a, id b, id c, id d, id e, id f) {
    NSMutableArray* lessonsArray = [[NSMutableArray alloc] init];
    [lessonsArray addObject:a];
    [lessonsArray addObject:b];
    [lessonsArray addObject:c];
    [lessonsArray addObject:d];
    [lessonsArray addObject:e];
    [lessonsArray addObject:f];
    return lessonsArray;
}

- (void)viewDidLoad {
    [super viewDidLoad];

monLessonArrayA = lessonArrayFuncTwo(monP1A, monP2A, monP3A, monP4A, monP5A, monP6A);
    monLessonArrayB = lessonArrayFuncTwo(monP1B, monP2B, monP3B, monP4B, monP5B, monP6B);
    tueLessonArrayA = lessonArrayFuncTwo(tueP1A, tueP2A, tueP3A, tueP4A, tueP5A, tueP6A);
    tueLessonArrayB = lessonArrayFuncTwo(tueP1B, tueP2B, tueP3B, tueP4B, tueP5B, tueP6B);
    wedLessonArrayA = lessonArrayFuncTwo(wedP1A, wedP2A, wedP3A, wedP4A, wedP5A, wedP6A);
    wedLessonArrayB = lessonArrayFuncTwo(wedP1B, wedP2B, wedP3B, wedP4B, wedP5B, wedP6B);
    thuLessonArrayA = lessonArrayFuncTwo(thuP1A, thuP2A, thuP3A, monP4A, thuP5A, thuP6A);
    thuLessonArrayB = lessonArrayFuncTwo(thuP1B, thuP2B, thuP3B, thuP4B, thuP5B, thuP6B);
    friLessonArrayA = lessonArrayFuncTwo(friP1A, friP2A, friP3A, friP4A, friP5A, friP6A);
    friLessonArrayB = lessonArrayFuncTwo(friP1B, friP2B, friP3B, friP4B, friP5B, friP6B);

    NSInteger count = [monLessonArrayA count];
    for (int i = 0; i < count; i++) {
        [monLessonArrayA replaceObjectAtIndex:i withObject:@"test"];
    }
}

So now here I am using a function to simply put the strings into several arrays, then it comes back tot he loop, where it loops through the arrays and puts the text into the objects. Can you see any issues?

Upon loading the app crashes giving a SIGBRT error.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T18:40:00+00:00Added an answer on May 16, 2026 at 6:40 pm

    Rather than figure out how to replace objects at particular indexes in a mutable array, I think you should take a step back and reconsider the design of your application.

    It appears that you’re trying to design an application that manages “lessons” for a week, and are trying to do it by brute-force: Representing the week’s lessons as a collection of arrays of strings.

    Rather than doing it that way, you should probably consider what alternative representations you could use to simplify the application. For example, rather than represent a particular day’s lessons as strings in particular arrays at particular indexes, you could instead represent scheduled lessons as instances of a Lesson class that not only has the name of the lesson, but also its day and whether it’s a morning or afternoon lesson:

    typedef enum {
        LessonMonday=1,
        LessonTuesday=2,
        LessonWednesday=3,
        LessonThursday=4,
        LessonFriday=5,
    } LessonDay;
    
    typedef enum {
        LessonSessionA=1,
        LessonSessionB=2,
    } LessonSession;
    
    @interface Lesson : NSObject
    @property (readwrite, copy) NSString *title;
    @property (readwrite) LessonDay day;
    @property (readwrite) LessonSesson session;
    
    - (id)initWithTitle:(NSString *)title day:(LessonDay)day session:(LessonSession)session;
    @end
    

    Now you only need to represent lessons that are actually scheduled, say in a scheduledLessons collection. Your user interface can tell when a lesson is scheduled and render that session as empty without you having to “fill in” an empty lesson; if you want to later schedule a lesson for a particular slot, just create a new instance of Lesson to represent the lesson in that slot and store it. This also makes it easier to do things like change an existing lesson’s slot without shoving data all around: You can just change the title of a lesson, or the day of a lesson, or the session, without disturbing other lessons. (Obviously in something like this you would want to check for conflicts as well, but again, that’s straightforward.)

    After you understand the basics of how to model something like this in code I’d strongly urge you to take a look at using Core Data for it rather than doing it by hand. Once you start dealing with things like persistence and searching, it will just be much easier to have Core Data actually implement the bulk of your data model for you than either doing it the way you showed in your question, or the way I’m showing you above. For example, using Core Data I’d probably model this as three entities — Lesson, Day and Session — where a Day is associated with two Sessions and a Session is associated with a Lesson.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a bunch of classes I want to rename. Some of them have
I am trying to have a bunch of Core Data objects (NSStrings) be added
Does Java and/or Spring have the concept of properties? I have bunch of domain
I have a bunch of files that I need to be able to transport
I have a bunch of latitude/longitude pairs that map to known x/y coordinates on
I have a bunch of .NET frameworks installed on my machine. I know that
I have a bunch of perfmon files that have captured information over a period
I have a bunch (hundreds) of files that are supposed to have Unix line
I have a bunch of PDF files and my Perl program needs to do
I have a bunch a values I would like to add together which are

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.