I think MCsessionid is a StringRef which can be nil rather than one which should be initialized to the empty string - i.e. if it is nil then there is no session... Therefore, you need to check MCsessionid == nil in what follows. I suggest taking another look at this method and see if it makes sense to update signatures of any methods it calls (for example, MCSessionStart is only called by this method).