के लिए डेटासोर्स के रूप में एनएसएमयूटेबलएरे का उपयोग कैसे करूं, मेरे पास डेटा (हार्ड कोडेड) के साथ एक एनएसएमयूटेबलएरे है।मैं अपने UITableView
मैं इन दो tableview तरीकों को लागू किया और आईबी में, मैं प्रतिनिधि और डेटा स्रोत
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [myArray count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"UITableViewCell"];
if (!cell) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"UITableViewCell"] autorelease];
}
cell.textLabel.text = [myArray objectAtIndex:[indexPath row]];
NSLog(@"Cell is %@", [myArray objectAtIndex:indexPath.row]);
return cell;
}
डेटा tableview में दिखाई नहीं देंगे निर्धारित किया है। मैं NSLog भाग गया है और मैं देख सकता हूं कि डेटा myArray में है।
मैंने कोड में एनएसएलॉग जोड़ा और ऐसा लगता है कि कोड कभी निष्पादित नहीं होता है। सवाल यह है कि मेरी सरणी कैसे बनाई जा रही है?
यहाँ कोड
- (id)init:(NSMutableArray *)theArray
{
[super init];
countryTable.delegate = self;
countryTable.dataSource = self;
UITapGestureRecognizer * tapRecognizer = [[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(viewTapped:)] autorelease];
[window addGestureRecognizer:tapRecognizer];
myArray = [[NSMutableArray alloc] init];
myArray = theArray;
return self;
}
आप 'एनएसएमयूटेबलएरे' कैसे बना रहे हैं? – WrightsCS