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 8477963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T18:36:46+00:00 2026-06-10T18:36:46+00:00

I want to add an object into an NSMutableArray: NSLog(@Object text: %@, object.text); NSLog(@Object:

  • 0

I want to add an object into an NSMutableArray:

NSLog(@"Object text: %@", object.text);
NSLog(@"Object: %@", object);
[appdelegate.objects addObject:object];
NSLog(@"Objects array size: %i", [appdelegate.objects count]);

This is the output:

Object text: This is the text
Object: <Object: 0x6e762c0>
Objects array size: 0

How is this possible, I add an object, on the next line, it is still empty. The NSMutableArray is not nil, because that would raise an exception.

Anybody a guess?

  • 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-06-10T18:36:48+00:00Added an answer on June 10, 2026 at 6:36 pm

    It would not raise an exception if it was nil. You can still message a nil object if it usually responds to that message. In this case, you’ll just get 0. I think you’re not allocating the array. Make sure you’re doing this:

    array = [[NSMutableArray alloc] init];
    

    As a debugging tip, if you’re unsure about the state of an object and want to make sure the object indeed exists and is ready to be used, use assert(appdelegate.objects); If the array is nil, your code will stop executing at this line. If it doesn’t stop at this line, then you know the object exists in memory.

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

Sidebar

Related Questions

I have this script where I want to add an object to an array
I have an array of objects and I want to add another object just
I want to add as many labels as objects in my array. but how
i am going to just add one UILabel into array as example NSMutablearray *labels
I have an NSMutableArray object that I want to add custom methods to. I
I want to add an object to the Global scope, and in order to
I want to add elements to arrays within an object that I access like
I'm doing a simple slideUp animation on an object. I want to add attribute
I have a scraping object basically. I want to be able to add POST
I have a situation where i want to add LinePragmas to CodeDom objects. But

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.