Reputation: 3430
I am currently learning Swift and I am experimenting with Core Data where I would like to save a linked list. To add an element at the end of the list I have a while-loop like this:
var curr = start
while (curr.nextElem != nil) {
curr = curr.nextElem
}
The problem is though that curr.next != nil
seems to be invalid, following error is shown: 'ListElem' is not convertible to UInt8
I noticed this error a few times before but always found a way around comparing but how can this be done in this case?
Upvotes: 0
Views: 303
Reputation: 126167
Your ListElem.nextElem
property seems to be returning an actual ListElem
, so it can never be nil. For it to be able to be nil, it has to be of optional type (ListElem?
).
Also, try the Xcode 6.3 beta — most of the error messages where Swift 1.1 said "I dunno what you're doing, so I'll just say you can't convert it to UInt8
" have been replaced with better diagnostics in Swift 1.2.
Upvotes: 1