ios - Objective-C - TableView Controller - 预期的表达

标签 ios objective-c

我是 Objective-C 和 iOS 的初学者,我尝试学习如何为 iOS 开发出色的应用程序。

我尝试创建一个 TableViewController,所以我创建了一个类,但是这段代码有一些问题,我不知道为什么。我在评论中的代码中描述了所有内容。

这是代码。

BooksTableViewController.m 

import "BooksTableViewController.h"

@implementation BooksTableViewController



- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil //Semantic Issue - Designated initializer missing a 'super' call to a designated initializer of the super class
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];// Parse Issue - Expected expression

if(self){
    self.title = @"Books";
    self.tabBarItem.image = [UIImage imageNamed:@"books8.png"];
    self.imiona = @[@"Pan Tadeusz", @"Potop", @"Lalka", @"Uczta dla wron", @"Symfonnia C++"];
}
return self;
}


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return self.imiona.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Title"];

if(cell == nil){
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Title"];
}

cell.textLabel.text = self.imiona[indexPath.row];

return cell; 
}

@end

谢谢你的帮助!

最佳答案

initWithNibNamenimNameOrNil有问题。您所要做的就是:更改此行

self = [super initWithNibName:<#nibNameOrNil#> bundle:nibBundleOrNil]; 

self = [super initWithNibName: nibNameOrNil bundle:nibBundleOrNil];

通知:<#nibNameOrNil#>nibNameOrNil

关于ios - Objective-C - TableView Controller - 预期的表达,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30055281/

相关文章:

iphone - 如何更改 ABPeoplePickerNavigationController 的 UINavigationBar 的颜色?

objective-c - 如何使用单个 NSValueTransformer 子类切换多个菜单项的标题

ios - Swift 闭包 : Cannot convert return expression of type '()' to return type 'LiveSearchResponse?'

ios - Google Places Autocomplete,按机构/餐馆过滤

ios - iPad/iOS7 : 'Page' modal view controller strange behaviour after presenting 'Full screen' view controller from it

iOS 不完整的字体(复选标记)?

objective-c - Swift 游戏中心认证

ios - 将数字格式化为百分比

ios - 从项目中提取NSDictionary

objective-c - 从 iPhone 上的 PNG 图像读取像素颜色值的简单方法?