• 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: nibs don't know about protocols?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: nibs don't know about protocols?


  • Subject: Re: nibs don't know about protocols?
  • From: Michael Ash <email@hidden>
  • Date: Wed, 2 Jun 2010 11:38:37 -0400

On Wed, Jun 2, 2010 at 11:00 AM, Matt Neuburg <email@hidden> wrote:
> On or about 6/1/10 12:01 PM, thus spake "Kyle Sluder"
> <email@hidden>:
>
>> On Tue, Jun 1, 2010 at 11:00 AM, Matt Neuburg <email@hidden> wrote:
>>> So... Are nibs just ignorant of protocols?
>>
>> I don't believe the nib loading machinery checks protocol conformance
>> when it hooks up outlets. It certainly doesn't check class identity,
>> so I wouldn't expect it to check protocol conformance either.
>
> But the nib itself does check class identity; you can't draw an outlet to an
> instance of the wrong class. So I'm left wondering, then why are you allowed
> to draw an outlet to an instance of a class that doesn't adopt the required
> protocol? This feels like a bug to me.

To be clear on terminology, "the nib" doesn't check anything, it's
just a file. Interface builder checks class identity, and would be the
one to check protocol conformance.

I wouldn't call it a bug, but it's certainly an omission.

> And the fact that you can hook up the UIApplication to a delegate that
> doesn't adopt UIApplicationDelegate and run the app and have everything
> work, with no complaints at any point, *really* feels like a bug, because in
> that case what's the protocol for?

The protocol exists primarily to eliminate the unusual and
difficult-to-discover concept of "informal protocol", and to make
explicit the link between the delegate parameter and the protocol.
ObjC tends to be built around duck typing, so if you defeat the type
system and hook up an object which doesn't declare conformance to
UIApplicationDelegate, but which still implements the requisite
methods, then it's only expected that things would work. The fact that
IB makes it really easy to defeat the type checking is something of a
separate issue.

> Maybe I should move this over to Xcode-tools list? I started here because
> protocols are a Cocoa / language thing, not a tools thing. Wht thnk? m.

Since this is an IB feature, or lack thereof, then definitely.

Mike
_______________________________________________

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

References: 
 >Re: nibs don't know about protocols? (From: Kyle Sluder <email@hidden>)
 >Re: nibs don't know about protocols? (From: Matt Neuburg <email@hidden>)

  • Prev by Date: Re: Simulating app termination
  • Next by Date: Spotlight-Style search menu
  • Previous by thread: Re: nibs don't know about protocols?
  • Next by thread: Zooming UIScrollViews
  • Index(es):
    • Date
    • Thread