Ios 使用领域获取单击的单元格引用对象
我在我的swift应用程序中使用Realm进行本地存储。 在TableViewController的顶部,我有以下内容:Ios 使用领域获取单击的单元格引用对象,ios,swift,realm,Ios,Swift,Realm,我在我的swift应用程序中使用Realm进行本地存储。 在TableViewController的顶部,我有以下内容: var rides : Results<Rides>! rides = Realm().objects(Rides) 当我这样做时,数据完全加载到我的单元格中: func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITable
var rides : Results<Rides>!
rides = Realm().objects(Rides)
当我这样做时,数据完全加载到我的单元格中:
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let customCell = tableView.dequeueReusableCellWithIdentifier("ridesCell", forIndexPath: indexPath) as! RidesViewCell
var ride: Rides = rides[indexPath.row]
customCell.setRide(ride) // This just sets labels in the cell...
return customCell
}
当用户点击手机时,我想获取我的乘车ID
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
dump(rides[indexPath.row])
var ride: Rides = rides[indexPath.row]
self.selectedRideId = ride.id
self.performSegueWithIdentifier("ridesListToMap", sender: self)
}
但是我的selectedRideId
总是空的…我不知道为什么??
知道我做错了什么吗
下面是上面转储的结果:
▿ Gleam.Rides #0
▿ super: RealmSwift.Object
- super: Rides {
id = B3C78163-30D4-445B-A2D7-B1D447AF3037;
distance = 0.09266282501476202;
avgSpeed = 24.65913043478261;
duration = 21.78935199975967;
startDate = 2015-08-27 16:09:28 +0000;
endDate = 2015-08-27 16:09:50 +0000;
userId = A32C8DDB-9A31-46AC-8264-0E5A12FDD157;
}
- id:
- distance: 0.0
- avgSpeed: 0.0
- duration: 0.0
- startDate: Aug 27, 2015, 6:40 PM
- endDate: Aug 27, 2015, 6:40 PM
- userId:
所以它得到了正确的结果,但是没有给我身份证(不确定为什么它会被列出两次…看起来输出来自调试器——因为Realm会为您的对象切换属性访问器,所以不一定要设置实例变量。您最好检查对象的
描述
属性。谢谢,但我是个noob,您能开发bi吗检查对象的description
属性意味着什么?