I think I solved the warning problem. I suspected my folder logic was wrong
so I cleaned it up, taking all class files from the project and adding them
back one by one. And it works fine, no warning anywhere !I had a duplicate
controller I had created by mistake and I thought I had gotten rid of.
Thanks

2009/5/31 Pierre Berloquin <pie...@berloquin.com>

> I get warning "UIViewController may not respond to '-vagTouchesBegan:'
> (Messages without a matching method signature will be assumed to return
> 'id' and accept '...' as arguments)" when I call the view controller from
> the sub view
>
> - (void) touchesBegan: (NSSet *)touches withEvent:(UIEvent *)event {
>
> [theViewController vagTouchesBegan:self];
>
> }
>
> even though vagTouchesBegan is properly declared in the controller's .h
>
> -(void)vagTouchesBegan:(id)sender;
>
> Also I follow your advice about retaining loopholes and use
>
> -(void)setViewController:(UIViewController *) vc{
>
> theViewController = vc;
>
> }
>
> So the warning remains puzzling. Note that it's displayed on the sub view
> .m page only, after the call line, not after the mention "Succeeded".
>
> Thanks for your tips.
>
>
>
>
> 2009/5/30 WT <jrca...@gmail.com>
>
>> On May 30, 2009, at 5:43 PM, Pierre Berloquin wrote:
>>
>>  Declaring in .h
>>>
>>> -(void)vagTouchesBegan:(id)sender;
>>> was my first impulse. But that's not enough.
>>>
>>
>> It's not clear from your two posts which method you're getting a warning
>> for. I thought it was for the -vagTouchesBegan method, but you claim it's
>> not. Please post the actual warning that you get from XCode.
>>
>>  About the memory problem, I suppose I should receive touchesBegan in the
>>> controller and sort out what I get ?
>>>
>>
>> No, that's not what I was referring to. I was referring to the fact that
>> if an object of class A retains an object of class B and that same object of
>> class B also retains the object of class A which retains it, then you have
>> what's called a retain cycle. That may cause you trouble if you're not
>> careful.
>>
>> The view controller already retains its view, so if you're passing the
>> view controller object to the view object for it to keep, then the view
>> object should NOT retain that view controller object. If what I just said
>> isn't completely clear to you, you should read
>>
>>
>> http://devworld.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/MemoryMgmt.html
>>
>> If that document is still a bit obscure, then you should search the web
>> for more accessible explanations. For instance,
>>
>>
>> http://stackoverflow.com/questions/791322/retain-cycles-why-is-that-such-a-bad-thing
>>
>> Note that it *is* ok for the view object to have a pointer to its view
>> controller. All I'm saying is that you should avoid retaining the view
>> controller in its view. Thus, instead of
>>
>> - (void) setViewController: (UIViewController*) vcontroller
>> {
>>    [viewController release];
>>    viewController = [vcontroller retain];
>> }
>>
>> (which is the typical setter for objects) you should have
>>
>> - (void) setViewController: (UIViewController*) vcontroller
>> {
>>    viewController = vcontroller; // Note: no release and no retain
>> }
>>
>> (atypical for objects, but necessary in this case to avoid a retain
>> cycle).
>>
>> Or, if you prefer to use properties, instead of
>>
>> @property (readwrite, nonatomic, retain) UIViewController* viewController;
>>
>> you should use
>>
>> @property (readwrite, nonatomic, assign) UIViewController* viewController;
>>
>> Wagner
>>
>>
>>  2009/5/30 WT <jrca...@gmail.com>
>>>
>>>  On May 30, 2009, at 4:40 PM, Pierre Berloquin wrote:
>>>>
>>>> [theViewController vagTouchesBegan:self];
>>>>
>>>>> QED
>>>>> There's still a warning that the view controller may not respond. But
>>>>> it
>>>>> works seamlessly.
>>>>> Can I get rid of the warning?
>>>>>
>>>>>
>>>> Yes, by declaring the method -vagTouchesBegan: in the header file of
>>>> your
>>>> view controller class.
>>>>
>>>> Something to be cautious about when storing in the view a pointer to its
>>>> view controller is that you may end up creating a retain cycle, since
>>>> the
>>>> view controller already retains its view. I would recommend that you
>>>> read
>>>> the documentation on memory management to make sure you don't create
>>>> unnecessary problems for yourself.
>>>>
>>>> Wagner
>>>>
>>>
>
>
> --
> Blogs : http://bibliobs.nouvelobs.com/blog/jeux-litteraires
>            http://pierre-berloquin.blogspot.com/
>
> Développement durable des neurones par le jeu de réflexion
> www.crealude.net
>
> Sustainable development of neurones through mind games
> www.crealude.net/us
>
> Que fait-on pour les mal-codants ?
>



-- 
Blogs : http://bibliobs.nouvelobs.com/blog/jeux-litteraires
           http://pierre-berloquin.blogspot.com/

Développement durable des neurones par le jeu de réflexion
www.crealude.net

Sustainable development of neurones through mind games
www.crealude.net/us

Que fait-on pour les mal-codants ?
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to