안녕하세요 저는 프로그래밍 장면이 처음인데 lynda.com을 사용하여 소규모 프로젝트에서 기술과 실습을 배우고 있습니다. 편지에 대한 강사 지침을 따랐지 만 우리의 결과는 아주 다릅니다. NSMutable Array 내 코스의 "name"문자열을 표의 셀 제목으로 표시하고 싶지만 앱을로드 할 때 아무 것도 나타나지 않습니다. 우둔한 아이를 제발 도와주세요! 여기 Xcode : 테이블에 데이터 표시
내 클래스의 코드이며, 구현 파일은 내 속성 여기#import "Class.h"
@implementation Course
@synthesize name,teacher,room;
@end
등을위한 synthesization 내 UITable 뷰 컨트롤러 클래스에 대한 코드가 포함
#import "ScheduleTableViewController.h"
@interface ScheduleTableViewController()
@end
@implementation ScheduleTableViewController
NSMutableArray *classes;
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
NSMutableArray *classes = [[NSMutableArray alloc]init];
Course *class = [[Course alloc]init];
[class setName:@"AP Psychology"];
[class setRoom:@"E203"];
[class setTeacher:@"Juiliette Forbes"];
[classes addObject:class];
[class setName:@"AP Literature"];
[class setTeacher:@"Kristen Holtz"];
[class setRoom:@"E207"];
[classes addObject:class];
[class setName:@"AP Physics"];
[class setTeacher:@"Peter Dalby"];
[class setRoom:@"D205"];
[classes addObject:class];
[super viewDidLoad];
}
- (void)viewDidUnload
{
[super viewDidUnload];
}
- (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [classes count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"ClassCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifier];
}
Course *current = [classes objectAtIndex:indexPath.row];
[cell.textLabel setText:[current name]];
return cell;
}
어떤 도움이됩니다 잘 부탁드립니다. 그리고 잘하면 내가 알아서 할 수 있습니다.
코드의 일부분이 올바르지 않습니다. '#import "Class.h" @ 구현 과정 @synthesize name, teacher, room; @ end' import Class.h 및 구현 과정? 또한 대리인을 제외하고 테이블 뷰의 ** 데이터 소스 **를 설정해야합니다. – esh
viewdidLoad()에서 redeclaration 데이터 소스 배열 클래스를 제거하면 코드가 완벽하게 작동합니다. – Vinodh
파일은 class.h라고 불리지 만 클래스의 이름을 "class"에서 변경해야합니다. 왜냐하면 그 코드가 기초 코드와 충돌하여 "course"로 변경 되었기 때문입니다. 데이터 소스의 재 선언에 관해서는 실제로 그것이 무엇인지 알지 못한다고 생각합니다. 내가 말했듯이 미안해 내가 좀 새로운거야 – Hammy