Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Swift 全局数组项中的本地指定常量产生垃圾。为什么?_Swift_Constants - Fatal编程技术网

Swift 全局数组项中的本地指定常量产生垃圾。为什么?

Swift 全局数组项中的本地指定常量产生垃圾。为什么?,swift,constants,Swift,Constants,我无法为常数赋值。 但是,我可以从数据数组中看到原始值: (lldb) po friendsArray[selectedItemIndex].lastName! "Umph" (lldb) po friendsArray[selectedItemIndex].firstName! "Ronald" 但当我将当前数组值指定给局部常量时: let fname = friendsArray[selectedItemIndex].firstName! // "Ronald" let lna

我无法为常数赋值。 但是,我可以从数据数组中看到原始值:
(lldb) po friendsArray[selectedItemIndex].lastName!
"Umph"
(lldb) po friendsArray[selectedItemIndex].firstName!
"Ronald"

但当我将当前数组值指定给局部常量时:

let fname = friendsArray[selectedItemIndex].firstName!    // "Ronald"
let lname = friendsArray[selectedItemIndex].lastName!     // "Umph"
我收到垃圾:

(lldb) po fname
"\xf0\xee\xae\x02\x01"

(lldb) po lname
"KLWR"

以下是我正在使用的资产:
enum FriendSelection:Int {
    case selectedFriends = 0
    case allFriends
}


为什么?

朋友的定义是什么?我已根据您的请求添加了资产定义。“朋友”本质上是“人”的同义词。我没有任何错误。您确定在订购时,已为其分配了价值吗?f0ee看起来像一些原始内存值。字符串是一个结构,我假设它们在堆栈中分配了空间,所以它们可能在初始化之前包含未初始化的值。
var friendsArray:[person] = []
struct person {
    var firstName:String?
    var lastName:String?
    var image:UIImage?
    var description:String?

    init(firstName:String, lastName:String) {
        self.firstName = firstName
        self.lastName = lastName
    }
}