Cannot add NSObject to NSMutableArray

Discussion in 'iOS Programming' started by mrl72, Jan 25, 2011.

  1. macrumors regular

    Joined:
    Apr 20, 2008
    #1
    Tearing my hair out over this one and not sure what I'm doing wrong. I have an object called "Feed" as such:

    Code:
    @interface Feed : NSObject {
    	NSString *feedId;
    }
    
    @property (nonatomic, copy) NSString *feedId;
    @end
    
    ----------
    @implementation Feed
    @synthesize feedId;
    
    ----------
    
    In a method in my viewcontroller :
    
    NSMutableArray *feedArray = [[NSMutableArray alloc] init];
    Feed *feed = [[[Feed alloc] init] autorelease];
    feed.feedId = @"test";
    [feedArray addObject:feed];
    NSLog([feedArray description]);
    
    This is what I get:

    2011-01-26 00:19:40.628 ffeed[33447:207] (
    (null)
    )

    I have another class I set up exactly the same way and that works fine and the code looks identical, so maybe I missed a step somewhere. But then again it is late!

    Any ideas?
     
  2. macrumors 6502

    Joined:
    Oct 31, 2007
    Location:
    San José
    #2
    When you call:

    [feedArray description];

    You can think of this as recursively asking each object in that array for its description. It looks like you haven't really taught your Feed objects how to describe themselves.
     
  3. thread starter macrumors regular

    Joined:
    Apr 20, 2008

Share This Page