Is the first parameter supposed to be an object? A tutorial I’m following has the first parameter being textFieldBeingEdited.text, where it is defined in the .h file as
UITextField *textFieldBeingEdited
Isn’t textFieldBeingEdited an object, and text is a property of that object?
The following code crashes:
[tempValues setObject:textFieldBeingEdited forKey:tagAsNum];
If I change it to the following then it doesn’t crash:
[tempValues setObject:textFieldBeingEdited.text forKey:tagAsNum];
That doesn’t make sense though since the first argument is supposed to be an object, and not a property.
A property is syntactic sugar for a getter method that returns an object and optionally a setter method that takes an object. The
textproperty of theUITextFieldobject provides a getter method that returns anNSStringobject that can be stored in anNSDictionary.Essentially, a property provides two methods. For example, the methods implemented/synthesised by the
textproperty may look like this (simplified for the sake of the example):When you use
object.text = @"Hello", it will actually send thesetText:message with@"Hello"as the argument, and when you useNSString *value = object.text;it will actually send thetextmessage, which returns anNSStringobject.