尝试将值附加到字典
private static SyncAdapter sSyncAdapter = null;
private static final Object sSyncAdapterLock = new Object();
@Override
public void onCreate() {
synchronized (sSyncAdapterLock) {
if (sSyncAdapter == null) {
sSyncAdapter = new SyncAdapter(getApplicationContext(), true);
}
}
}
我对成员'下标'在public typealias Parameters = [String: Any]
var parameters: Parameters = [
"username" : username,
"first_name" : firstName,
"last_name" : lastName,
"profession" : profession
]
if let imageURl = imageUrl {
parameters[4] = ["image_url" : imageUrl]
}
行
我该如何解决这个问题?
答案 0 :(得分:3)
您应该通过parameters
密钥访问String
字典,即"image_url"
,而不是其索引4:
if let imageURl = imageUrl {
parameters["image_url"] = imageUrl
}