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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:50:49+00:00 2026-05-28T00:50:49+00:00

Hello I created a app on iOS 4.3.3 and than downloaded Xcode 4.2.1 and

  • 0

Hello I created a app on iOS 4.3.3 and than downloaded Xcode 4.2.1 and iOS sdk 5. It’s a navigation-based application and it has a mutable array for the tableview but it won’t create any strings for the array, so i added an object to array in the viewdidload but it is not working! So i added NSlog to the objects in my array and it says null! What should i do?

Here’s the viewdidload:

    - (void)viewDidLoad
    {
    [super viewDidLoad];
    self.soldc = [NSMutableArray arrayWithCapacity:0];
    self.color = [NSMutableArray arrayWithCapacity:0];
    appdelegate = (yard_sale_managerAppDelegate *)[[UIApplication sharedApplication]          delegate];
    appdelegate.object = self;
    NSMutableArray *loadi = [[NSMutableArray alloc]initWithCapacity:0];
    self.items = loadi;
    self.sold = [NSMutableArray arrayWithCapacity:0];
    self.prices = [NSMutableArray arrayWithCapacity:0];

    alert = [[UIAlertView alloc] initWithTitle:@"Add product" message:@"Enter your   product name and price." delegate:self cancelButtonTitle:@"Add" otherButtonTitles:@"Cancel",   nil];
    [alert addTextFieldWithValue:@"" label:@"name"];
    [alert addTextFieldWithValue:@"" label:@"price"];
    add = [alert textFieldAtIndex:0];
    add.keyboardType = UIKeyboardTypeAlphabet;
    add.keyboardAppearance = UIKeyboardAppearanceAlert;
    add.autocapitalizationType = UITextAutocapitalizationTypeWords;
    add.autocorrectionType = UITextAutocorrectionTypeNo;
    add2 = [alert textFieldAtIndex:1];
    add2.keyboardType = UIKeyboardTypeNumberPad;
    add2.keyboardAppearance = UIKeyboardAppearanceAlert;
    add2.autocapitalizationType = UITextAutocapitalizationTypeWords;
    add2.autocorrectionType = UITextAutocorrectionTypeNo;
    NSLog(@"%i", [color count]);
    alert.tag=1;
    self.resa = [[UIAlertView alloc] initWithTitle:@"Sale results" message:@"temple" delegate:self cancelButtonTitle:@"Close" otherButtonTitles: nil];
    self.items = [NSMutableArray arrayWithContentsOfFile:[self itemsp]];
    self.prices = [NSMutableArray arrayWithContentsOfFile:[self pricesp]];
    self.sold = [NSMutableArray arrayWithContentsOfFile:[self soldp]];
    self.soldc = [NSMutableArray arrayWithContentsOfFile:[self soldcp]];
    self.color = [NSMutableArray arrayWithContentsOfFile:[self colorsp]];
    if ([self.soldc count]==0) {

    }
    //self.soldc = [NSMutableArray arrayWithContentsOfFile:[self soldcp]];
    self.color = [NSMutableArray arrayWithContentsOfFile:[self colorsp]];
    [loadi release];
    self.resa.tag = 2;
    [self.items addObject:@"chair"];   
    [self.prices addObject:@"30"];
    [self.color addObject:@"0"];
    NSLog(@"%@",self.items);
}

If you need more information tell me!
This is the log:

2012-01-08 21:31:13.409 yard sale manager[1152:f803] 0
2012-01-08 21:31:13.411 yard sale manager[1152:f803] (null)

edit: read this its important!!!!!
a lot of people didn’t notice that piece of code:
[self.items addObject:@”chair”];
[self.prices addObject:@”30″];
[self.color addObject:@”0″];
NSLog(@”%@”,self.items);

  • 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-28T00:50:49+00:00Added an answer on May 28, 2026 at 12:50 am

    This line

    self.color = [NSMutableArray arrayWithCapacity:0];
    

    instantiates and assigns an empty array, you then do not add anything to it therefore the 0 count.

    Then this line

    self.items = [NSMutableArray arrayWithContentsOfFile:[self itemsp]];
    

    is probably the cause. Does [self itemsp] return a valid file path that points to a file that can be parsed into an NSArray.

    There are also a lot of other issues with this code.


    Update

    This line

    self.items = [NSMutableArray arrayWithContentsOfFile:[self itemsp]];
    

    must be returning nil.

    Confirm by adding this line straight after it

    NSLog(@"%@", self.items);
    

    How can I make this assumption

    The reason I am making this assumption is because you are getting (null). When you call addObject: on nil you will get nil returned and it is a no-op. As you can see from this snippet

    NSMutableArray *myArray = nil;
    
    [myArray addObject:@"Test"];
    
    NSLog(@"%@", myArray);
    
    // => 2012-01-08 20:54:04.708 Untitled[4199:707] (null)
    

    Just because myArray holds a pointer to an NSMutableArray it does not mean that you actually have one.

    Therefore the last time you assign to self.items is in:

    self.items = [NSMutableArray arrayWithContentsOfFile:[self itemsp]];
    

    which means [NSMutableArray arrayWithContentsOfFile:[self itemsp]] is returning nil

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

Sidebar

Related Questions

I just created my first application for Google App Engines, which is called Hello
Hello i'm trying to make a simple ios app with tabs and navigation .
I have created a simple Hello World Application using Flash Builder Burrito SDK. I
I've created a WebView-based application according to http://developer.android.com/resources/tutorials/views/hello-webview.html Although I did exactly what was
I have the following problem: I created a iOS 5 SDK application with Storyboard
hello i have created one windows application in c# .net and its working fine
hello all I have a small dialog which I created dynamically, which has a
I have created a very basic Hello world application where I am trying to
I created a Hello world app but get this strange error: The project cannot
I created a sample hello world application using Flash Builder 4.5.1 (with the update

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.