我想從我的self.view中將NSArray傳遞給子視圖,這裏是我的代碼。將NSArray從self.view傳遞給子視圖
mainView.h
NSArray *rssData;
@property(nonatomic,retain)NSArray *rssData;
mainView.m
@synthesize rssData;
MySubView *datacarry = [[MySubView alloc] init];
for (int i = 0; i<rssOutputData.count; i++) {
self.rssData = [[NSArray alloc] initWithObjects:
[NSDictionary dictionaryWithObjectsAndKeys:[[rssOutputData objectAtIndex:i]xmlhotel_name], @"hotelname",
[[rssOutputData objectAtIndex:i]xmlhotel_price], @"startingfrom",
[[rssOutputData objectAtIndex:i]xmlhotel_city],@"city",
[[rssOutputData objectAtIndex:i]xmlhotel_distance],@"distance",
[[rssOutputData objectAtIndex:i]xmlhotel_image],@"imagesnames",
[[rssOutputData objectAtIndex:i]xmlhotel_stars],@"numberofstars",
[[rssOutputData objectAtIndex:i]xmlhotel_id],@"hotelid",
@"45.5016889",@"hotelLat",
@"-73.567256",@"hotelLong", nil],nil];
datacarry.rssData = self.rssData;
nslog(@"%@",datacarry.rssData); // here i can see data that is is transferred
}
這裏是我的子視圖是MySubView
MySubView.h
NSArray *rssData;
@property(nonatomic,retain)NSArray *rssData;
MySubView.m
@synthesize rssData;
//rssData= [[NSArray alloc] init];
nslog(@"%@",rssData); // here i can see NO DATA
好了,你不必再頁頭中的init的mySUbView。 –
即使然後我不能在nsSUbView –
嘗試強烈而不是保留nslog數據。你在哪裏在mySUbView中做NSLOg? –