swift - Parse.com, disable a UIButton based on an object value -
i try build system parse. here's how try that: first when user click on button, associate post id user:
@ibaction func likebuttonpressed(sender: anyobject) { var id: anyobject! = self.object.objectid let user = pfuser.currentuser() user.addobject(id, forkey: "liked") user.save()
this part work correctly. now, want sure user each post once. that,
check if post id value allready (or not) in liked list
var liked = pfuser.currentuser().objectforkey("liked") [string] id in liked{ if id == id{ found = true } } if found{ likebutton.enabled = false } else{ likebutton.enabled = true }
if post id in liked list likebutton disable. unfortunately last part doesn't work (the button stil clickable). i'm beginner don't see where's problem code thank much
if id == id
while not familiar swift, comparison hold true. try renaming 1 of variables comparing.
Comments
Post a Comment