我看到本地生成的用户的objectId和匿名登录后创建的用户不一样。
例如
var dictionary: NSDictionary
init(dictionary: NSDictionary) {
self.dictionary = dictionary
}
var business: String {
get {
return self.dictionary["businesses"] as! String
}
}
var name: String {
get {
return self.dictionary["name"] as! String
}
}
var phone: String {
get {
return self.dictionary["phone"] as! String
}
}
var rating: String {
get {
return self.dictionary["rating"] as! String
}
}
var imageURL: NSURL? {
get {
if let image = self.dictionary["image_url"] as? String {
return NSURL(string: image.stringByReplacingOccurrencesOfString("ms.jpg", withString: "ls.jpg", options: nil, range: nil))
}
return nil
}
}
var ratingImageURL: NSURL {
get {
return NSURL(string: self.dictionary["rating_img_url_large"] as! String)!
}
}
var reviewCount: Int {
get {
return self.dictionary["review_count"] as! Int
}
}
var deals: Array<AnyObject>? {
get {
if let deals = self.dictionary["deals"] as? Array<AnyObject> {
return deals
}
return nil
}
}
var latitude: Double? {
get {
if let location = self.dictionary["location"] as? NSDictionary {
if let coordinate = location["coordinate"] as? NSDictionary {
return (coordinate["latitude"] as! Double)
}
}
return nil
}
}
var longitude: Double? {
get {
if let location = self.dictionary["location"] as? NSDictionary {
if let coordinate = location["coordinate"] as? NSDictionary {
return (coordinate["longitude"] as! Double)
}
}
return nil
}
}
var location: CLLocation {
get {
return CLLocation(latitude: self.latitude!, longitude: self.longitude!)
}
}
var shortAddress: String {
get {
if let location = self.dictionary["location"] as? NSDictionary {
if let address = location["address"] as? Array<String> {
if let neighborhoods = location["neighborhoods"] as? Array<String> {
return ", ".join(address + [neighborhoods[0]])
}
return ", ".join(address)
}
}
return ""
}
}
var displayAddress: String {
get {
if let location = self.dictionary["location"] as? NSDictionary {
if let address = location["display_address"] as? Array<String> {
return ", ".join(address)
}
}
return ""
}
}
var displayCategories: String {
get {
if let categories = self.dictionary["categories"] as? Array<Array<String>> {
return ", ".join(categories.map({ $0[0] }))
}
return ""
}
}
我希望obj1在匿名登录阶段持续存在。
我可以以某种方式&#34;附加&#34;本地创建的用户并匿名登录他?或者是自动生成的用户仅在您稍后将其升级为用户&amp; pass / social based登录时才有用?
答案 0 :(得分:1)
PFAnonymousUtils.logInWithBlock
定义为销毁现有匿名用户数据并创建新的干净匿名用户。您应该只在用户注销时才这样做。
如果启用匿名用户,则最初会创建一个用户,您可以添加所需的任何详细信息。然后,稍后,当用户希望真实帐户使用signUp:
上的PFUser
进行转换时。
请注意,匿名用户并非真实,您无法将其用于所有内容。因此,您可能会遇到与其他用户实际参与的问题。如果是这种情况,那么您可能需要使用自动生成的登录详细信息创建真正的占位符用户,并在以后通过更新用户名并发送忘记的密码电子邮件(或类似信息)来转换它。