• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: [iPhone] Why can't a UITextField be its own delegate?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [iPhone] Why can't a UITextField be its own delegate?


  • Subject: Re: [iPhone] Why can't a UITextField be its own delegate?
  • From: WT <email@hidden>
  • Date: Sat, 25 Jul 2009 21:39:37 +0200

On Jul 25, 2009, at 9:17 PM, Brian Slick wrote:

I won't pretend to know the answer, but this struck me as odd:

On Jul 25, 2009, at 3:06 PM, WT wrote:

- (void) awakeFromNib
{
  super.delegate = self;
  super.text = @"Hello world";

  NSLog(@"awakeFromNib called - delegate set to self");
}


Shouldn't it be [self setDelegate: self]? I wouldn't think you'd have an actual 'super' object available to perform the delegate methods.

But I probably don't understand.

Brian

The reason is simple, though probably not obvious.

I still might need the text field to have an "outside" delegate, which I maintain by having an additional outlet reserved for that delegate. Then, I override -delegate to return that outlet and -setDelegate: to set it.

That way, the field can be its own true delegate and do its job, while also allowing an outside object to serve as a delegate and participate in the editing session. As far as the outside world is concerned, it's business as usual.

But once I have an overridden -setDelegate:, I can't use self.delegate = self to set the field as its own true delegate, because that will execute the overridden method.

Wagner
_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
This email sent to email@hidden


  • Follow-Ups:
    • Re: [iPhone] Why can't a UITextField be its own delegate?
      • From: Luke the Hiesterman <email@hidden>
References: 
 >[iPhone] Why can't a UITextField be its own delegate? (From: WT <email@hidden>)
 >Re: [iPhone] Why can't a UITextField be its own delegate? (From: Brian Slick <email@hidden>)

  • Prev by Date: Re: NSDictionary crash
  • Next by Date: Re: NSDictionary crash
  • Previous by thread: Re: [iPhone] Why can't a UITextField be its own delegate?
  • Next by thread: Re: [iPhone] Why can't a UITextField be its own delegate?
  • Index(es):
    • Date
    • Thread