I'm trying to set up tableViewCell properties to different Labels. However i keep getting errors regarding the Strings. I've started by hooking the array up like this.
cell.titleViewLabel.text = arrayNews[indexPath.row].title
However i keep getting this error
cannot assign a value of type nsstring to a value of type string
How can i format the above title to a NSString so i don't get this error in cellForRowAtIndexPath? or this due to something else?
Problem:
The root of the problem is as follows:
cell.titleViewLabel.text
is NSString
arrayNews[indexPath.row].title
is string
Solution:
You need to cast your string
to NSString
. Try the following syntax
cell.titleViewLabel.text = arrayNews[indexPath.row].title as NSString
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.