将对象C转换为Swift fetchRequest

时间:2016-05-30 16:00:37

标签: ios objective-c swift converter

我在Objective-C

中有代码
NSFetchRequest *fetchRequest = [NSFetchRequest fetchRequestWithEntityName:@"Doctor"];
[fetchRequest setPredicate:[NSPredicate predicateWithFormat:@"id != nil"]];
fetchRequest.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"distance" ascending:YES], [NSSortDescriptor sortDescriptorWithKey:@"lastname" ascending:YES]];

并尝试转换为Swift

var fetchRequest: NSFetchRequest = NSFetchRequest(entityName: "Doctor")
fetchRequest.predicate = NSPredicate(format: "id != nil")
let disctanceSortDescriptor = NSSortDescriptor(key:"distance",ascending: true)
let lastNameSortDescriptor = NSSortDescriptor(key:"lastname",ascending: true)
 fetchRequest.sortDescriptors = NSSortDescriptor(key:"distance",ascending: true), NSSortDescriptor(key:"lastname",ascending: true)

如何将Objective-C转换为Swift

fetchRequest.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"distance" ascending:YES], [NSSortDescriptor sortDescriptorWithKey:@"lastname" ascending:YES]];

1 个答案:

答案 0 :(得分:0)

我认为你需要的是这个

<a href='http://something.com/Folder/Index?showId=@item.id'>Edit</a>

希望这对你有帮助!