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

  • Home
  • SEARCH
  • 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 7756981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:57:50+00:00 2026-06-01T12:57:50+00:00

In one class, I define an NSMutableArray with getters and setters: @interface ArrayClass :

  • 0

In one class, I define an NSMutableArray with getters and setters:

@interface ArrayClass : NSObject {
    NSMutableArray *array;
}
@property (nonatomic, strong) NSMutableArray *array;

@end

Then within the implementation file, I alloc init the mutable array:

#import "ImageUploader.h"

@implementation ArrayClass
@synthesize array;

- (id)init {
    self = [super init];
    if (self != nil) {
        NSLog(@"ArrayClass inited");
        array = [[NSMutableArray alloc] init];
    }
    return self;
}

@end

Then I initialize an instance of this class from another class:

ArrayClass *arrayClass = [[ArrayClass alloc] init];
                [arrayClass.array addObject:image];
                NSUInteger count = [arrayClass.array count];
                NSLog(@"%@", count);

But when I try to add an object to the mutable array, the app crashes and Xcode 4.3 shows:
enter image description here

Removing the addObject call makes the app run fine. What am I doing wrong that would cause the app to crash?

  • 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-01T12:57:52+00:00Added an answer on June 1, 2026 at 12:57 pm

    This is wrong:

    NSUInteger count = [arrayClass.array count];
    NSLog(@"%@", count);
    

    You want:

    NSLog(@"%u", count);
    

    %@ is used to specify that the argument is an object. However, an NSUInteger is a primitive value, not an object. You use %u for unsigned ints.

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

Sidebar

Related Questions

Is there anyway that i can define an NSString. Inside of one class then
I know that one can define an 'expected' exception in JUnit, doing: @Test(expect=MyException.class) public
Im attempting to pass an array that is created in one class into another
c# enables us to define more than one class with the method. Main method
I have one class, called A, and it has it's own header file. Then
hi i defined one class to create cookie by received parameter's from user. when
If I have the core of a class defined in one file as public
I have two different projects and in one, I have a class that defines
Assuming one has an abstract base class foo with __get() defined, and a child
In one class I have a library project with a file class1 with namespace

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.