title: Having a unrecognized selector sent to instance based on a button selected state
body: <p>I have a button in a UIControllerView set to follow a particular user with the Parse.com backend.</p>
  
  <p>I want this behavior :</p>
  
  <p>-> user is not a friend, button state = unselected, perform following action in Parse.com => change button state to selected</p>
  
  <p>-> user is a friend, button state = selected, perform unfollowing action in parse.com => change button state to unselected</p>
  
  <p>My problem is : </p>
  
  <p>if the button is selected (because user is already a friend) = > everything work good</p>
  
  <p>if the button IS NOT selected (because user is not a friend) => </p>
  
  <pre><code> Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Sliked.FriendsProfileViewControler followButton:]: unrecognized selector sent to instance    0x7f7f7ad63370'
    *** First throw call stack:
   (
     0   CoreFoundation                      0x000000010aabe3f5 __exceptionPreprocess + 165
     1   libobjc.A.dylib                     0x000000010c5ecbb7 objc_exception_throw + 45
     2   CoreFoundation                      0x000000010aac550d -[NSObject(NSObject)    doesNotRecognizeSelector:] + 205
     3   CoreFoundation                      0x000000010aa1d7fc ___forwarding___ + 988
     4   CoreFoundation                      0x000000010aa1d398 _CF_forwarding_prep_0 + 120
     5   UIKit                               0x000000010b3499ee -[UIApplication sendAction:to:from:forEvent:] + 75
     6   UIKit                               0x000000010b44fbd0 -[UIControl _sendActionsForEvents:withEvent:] + 467
     7   UIKit                               0x000000010b44ef9f -[UIControl touchesEnded:withEvent:] + 522
     8   UIKit                               0x000000010b38f3b8 -[UIWindow _sendTouchesForEvent:] + 735
     9   UIKit                               0x000000010b38fce3 -[UIWindow sendEvent:] + 683
    10  UIKit                               0x000000010b35cae1 -[UIApplication sendEvent:] + 246
    11  UIKit                               0x000000010b369bad _UIApplicationHandleEventFromQueueEvent + 17370
    12  UIKit                               0x000000010b345233 _UIApplicationHandleEventQueue + 1961
    13  CoreFoundation                      0x000000010a9f3ad1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    14  CoreFoundation                      0x000000010a9e999d __CFRunLoopDoSources0 + 269
    15  CoreFoundation                      0x000000010a9e8fd4 __CFRunLoopRun + 868
    16  CoreFoundation                      0x000000010a9e8a06 CFRunLoopRunSpecific + 470
    17  GraphicsServices                    0x000000010db299f0 GSEventRunModal + 161
    18  UIKit                               0x000000010b348550 UIApplicationMain + 1282
    19  Sliked                              0x0000000109273a4e top_level_code + 78
    20  Sliked                              0x0000000109273a8a main + 42
    21  libdyld.dylib                       0x000000010cdc6145 start + 1
     )
     libc++abi.dylib: terminating with uncaught exception of type NSException
  </code></pre>
  
  <p>My code look like this :</p>
  
  <pre><code>    @IBOutlet var followUnfollowButton: UIButton!
  
      @IBAction func followUnfollow (sender: AnyObject) {
  
  
  
      let user:PFObject = userPassed
      let currentUser = PFUser.currentUser()
      let relation : PFRelation = currentUser.relationForKey("KfriendsRelation")
  
      if  !followUnfollowButton.selected {
  
          followUnfollowButton.selected = true
  
          followUnfollowButton.setTitle("Unfollow", forState: UIControlState.Selected)
          followUnfollowButton.backgroundColor = UIColor(red: 117/255, green: 201/255, blue: 223/255, alpha: 1.0)
  
          relation.addObject(user)
  
          PFUser.currentUser().saveInBackgroundWithBlock { (succeed:Bool, error: NSError!) -&gt; Void in
              if error != nil {
                  println("not working")
              }
  
  
  
              println("following user succes")
  
          }
  
      }
  
      else  {
  
  
          followUnfollowButton.selected = false
          followUnfollowButton.backgroundColor = UIColor(red: 248/255, green: 255/255, blue: 9/255, alpha: 1.0)
  
  
          relation.removeObject(user)
  
          PFUser.currentUser().saveInBackgroundWithBlock{   (succeed:Bool, error: NSError!) -&gt; Void in
  
              if error != nil {
                  println(error)
                  println("can't unfollow user")
              }
          }
      }
  
  
  }
  </code></pre>
  
  <p>I tried to remove the Parse logical, just to test if the changes to the selected state are working good when i push the button but have the same error. </p>
  
  <p>This is very strange, what did i miss ?</p>