Okay, I still don't get why Swift has this stupid ! and ? syntax. Why not just:
1) Explicitly state that object references must be tested for nil before use (like C,C++, etc...), or 2) Use the ObjC behavior that sending a message to nil does nothing (unless the message returns something other than void, in which case you'll get some all-zero-bits equivalent return value, and you can still test for nil if you want) ??Why make up this silly crap and ruin an otherwise good language?? Is this one of those optimization things that makes Swift faster? -------- end rant -------- Where I'm running into problems is this line of code: func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { var cell = tableView.dequeueReusableCellWithIdentifier(simpleTableIdentifier) as? UITableViewCell if (cell == nil) { cell = UITableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: simpleTableIdentifier) } cell!.textlabel.text = dwarves[indexPath.row] // Problem here return cell } Xcode is complaining that a "?" or "!" is needed after "textLabel", and before the ".text", but I don't really understand which one to use. Another line of code that confuses me is the first line: var cell = tableView.dequeueReusableCellWithIdentifier(simpleTableIdentifier) as? UITableViewCell yet they use an "!" and not a "?" in the cell!.textLabel.text... line. Shouldn't that be: cell?.textLabel.text to match up with the ? in the var cell... line? P.S. This code is in Chapter 8 of the book "Beginning iPhone Development with Swift: Exploring the iOS SDK" on page 254. _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com