0
我從下面一雷Wenderlich教程的plist這是在Objective C.編碼我掙扎,下面的代碼從目標C轉換爲斯威夫特填充表用數據填充表:從plist中
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
NSSortDescriptor* sortDescriptor = [NSSortDescriptor sortDescriptorWithKey:nil ascending:YES selector:@selector(localizedCompare:)];
NSArray* sortedCategories = [self.articleDictionary.allKeys sortedArrayUsingDescriptors:[NSArray arrayWithObject:sortDescriptor]];
NSString *categoryName = [sortedCategories objectAtIndex:section];
NSArray *currentCategory = [self.articleDictionary objectForKey:categoryName];
return [currentCategory count];
}
當我轉換如下:
var sortDescriptor:NSSortDescriptor = NSSortDescriptor(key: nil, ascending: true, selector: "localizedCompare:")
我得到一個編譯器錯誤呼叫
指出「額外的參數‘選擇’,然後當我嘗試以下行我得到XCode暗示我使用:
let sortedCategories:NSArray = [articleDictionary.allKeys.sort(<#isOrderedBefore: (AnyObject, AnyObject) -> Bool##(AnyObject, AnyObject) -> Bool#>)]
有什麼建議嗎?