开发者

How do I populate an NSMutableArray in one class with another object?

开发者 https://www.devze.com 2023-02-13 14:53 出处:网络
I know this is a simple answer, but I can\'t seem to find the solution.I created an object in its own class and I am trying to populate it with data from another class.For simple data types like NSStr

I know this is a simple answer, but I can't seem to find the solution. I created an object in its own class and I am trying to populate it with data from another class. For simple data types like NSString, I have no problem, but when trying make an NSMutableArray equal to another NSMutableArray or when I try to populate a NSMutableArray with another objects (like strings), I keep getting exception errors...

Here is the object I am trying to populate:

#import <Foundation/Foundation.h>


@interface RSSFeedList : NSObject {

NSString *subject;
NSMutableArray *rssfeedDetail;

}

@property (nonatomic, retain) NSString *subject;
@property (nonatomic, retain) NSMutableArray *rssfeedDetail;

@end

This is how I was able to populate the NSString 'subject' in another class:

rssFeedList.subject = @"test";

However, if I follow similar convention 开发者_运维问答within that same class with respect to an Array, it throws an exception:

rssFeedList.rssfeedDetail = rssItemDetailArray;

Where rssItemDetailArray is a NSMutableArray that I have built in the same class.

I have also tried to add items (i tried strings for testing) to the NSMutableArray directly like so to no avail:

[rssFeedList.rssfeedDetail addObject:@"test"];

Any ideas?? Thanks in advance!!


I'm almost certain that you've forgotten to synthesize rssfeedDetail.

0

精彩评论

暂无评论...
验证码 换一张
取 消