我试图简单地将对象添加到可变数组中,但它们不会插入。我没有收到错误或任何错误,我不知道发生了什么。
在我的主委托文件中,我将一个数组分成 4 个单独的字符串,如下所示。
NSArray *split=[currentParsedCharacterData componentsSeparatedByString:@"|"];
NSLog([split objectAtIndex:3]);
NSString *date=[split objectAtIndex:0];
NSString *venue=[split objectAtIndex:1];
NSString *event=[split objectAtIndex:2];
NSString *city=[split objectAtIndex:3];
我已经查出了字符串值,它们肯定在那里。
接下来我尝试将这些字符串值添加到可变数组中
[self.promoTabOptionEvents.dates addObject:date];
[self.promoTabOptionEvents.venues addObject:venue];
[self.promoTabOptionEvents.event addObject:event];
[self.promoTabOptionEvents.city addObject:city];
当我检查调试器中的数组时,它们是空的。我究竟做错了什么?
promoTabOptionEvents 类看起来像这样
import
@interface PromoTabOptionEvents : UIViewController {
NSString *event_headline;
NSMutableArray *dates;
NSMutableArray *venues;
NSMutableArray *event;
NSMutableArray *city;
}
@property(nonatomic,retain)NSString *event_headline;
@property(nonatomic,retain)NSMutableArray *dates;
@property(nonatomic,retain)NSMutableArray *venues;
@property(nonatomic,retain)NSMutableArray *event;
@property(nonatomic,retain)NSMutableArray *city;
-(void)applyLabels;
-(id)initWithTabBar;
@end
#import "PromoTabOptionEvents.h"
@implementation PromoTabOptionEvents
@synthesize event_headline;
@synthesize dates;
@synthesize venues;
@synthesize event;
@synthesize city;
-(id) initWithTabBar {
if ([self init]) {
//this is the label on the tab button itself
//self.title = @"Tab1";
//use whatever image you want and add it to your project
self.tabBarItem.image = [UIImage imageNamed:@"events.png"];
// set the long name shown in the navigation bar
self.navigationItem.title=@"Events";
CGRect bgframe;
bgframe.size.width=320; bgframe.size.height=460;
bgframe.origin.x=0; bgframe.origin.y=0;
UIImage* bgimage = [UIImage imageNamed:@"eventsbig.png"];
UIImageView *imagebgview = [[UIImageView alloc] initWithImage: bgimage];
imagebgview.frame=bgframe;
imagebgview.contentMode=UIViewContentModeScaleAspectFit;
self.view.backgroundColor=[UIColor whiteColor];
[self.view addSubview:imagebgview];
}
return self;
}