Re: readonly IBOutlet autosynthesized property new warning
Re: readonly IBOutlet autosynthesized property new warning
- Subject: Re: readonly IBOutlet autosynthesized property new warning
- From: Aaron Montgomery <email@hidden>
- Date: Thu, 31 Jan 2013 08:15:08 -0800
Alas, I spoke too soon and was misremembering my code. When I tested at home, I could get the warning to go away, but I didn't actually run the app. Now that I run the app, it crashes (the class is not key value coding-compliant for the IBOutlet, this makes sense when I think about it). Checking the files where I thought I had done this trick, I discovered that I had written notes to myself that I had tried the trick and it didn't work. So I'm basically exactly where Roland is (with @synthesize statements to silence the warning). My testing categories have readonly properties to access the UIView outlets, but under different names so they don't conflict with the IBOutlet properties in the class proper.
Aaron
On Jan 31, 2013, at 6:50 AM, Aaron Montgomery <email@hidden> wrote:
> I will try to dupe Roland's bug with the following information so it gets into the system, but here's another way to get around the warning. I primarily expose the IBOutlets for the purposes of unit testing view controllers, so I had my readonly declarations in a category (defined in a separate header file that is only imported in unit test implementations). The following sequence of declarations does not trigger the warning:
>
> @interface MWViewController : UIViewController
> @end
>
> @interface MWViewController(Testing)
> @property (readonly) IBOutlet UIButton* button;
> @end
>
> @interface MWViewController ()
> @property (readwrite) IBOutlet UIButton* button;
> @end
>
> @implementation MWViewController
> //no synthesize
> @end
>
> Aaron
>
> On Jan 31, 2013, at 5:42 AM, Roland King <email@hidden> wrote:
>
>>
>> On 31 Jan, 2013, at 6:13 PM, Roland King <email@hidden> wrote:
>>
>>>
>>> On 31 Jan, 2013, at 2:08 PM, Joar Wingfors <email@hidden> wrote:
>>>
>>>> Hi Roland,
>>>>
>>>> I haven't seen that issue before. That's a bit of a surprise to me.
>>>>
>>>> In any case, you may not know that you don't have to have the property in the header if IB is the only one needing it. Your solution in this case may be to just remove the readonly declaration from the header.
>>>>
>>>> Joar
>>>>
>>>
>>> I do need them, these are the UILabels and UIOtherThings which need to be updated as the model object for which my UIView subclass is the view, changes. And sometimes I also need them not just internally in the class itself, but I need to export them readonly so other people can use them. A good use case for that is one of the ones which had this warning, a UITableViewCell subclass which loads the UI from a NIB, and exports some of the UI elements loaded as readonly properties so that the table view data source can configure them in cellForRowAtIndexPath:.
>>>
>>> This should be pretty easy to distill down, if I can come up with a decent short project showing this I'll file it.
>>>
>>> Thanks
>>
>> rdar://13123861
>>
>> A little verbose but hopefully clear.
>> _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> Xcode-users mailing list (email@hidden)
>> Help/Unsubscribe/Update your Subscription:
>>
>> This email sent to email@hidden
>
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Xcode-users mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden