Re: swift and objective-c
Re: swift and objective-c
- Subject: Re: swift and objective-c
- From: Mike Manzano <email@hidden>
- Date: Tue, 03 Jun 2014 09:29:27 -0700
It's true that Swift is strongly typed, but if you consider "id" to be a type that's the "supertype" of any other type, objc is strongly typed too.
In Swift, you can use "AnyObject" much like "id". This is all legal:
let someObject : AnyObject = 5
let anotherObject : AnyObject = ["an","array"]
let yetAnotherObject : AnyObject = "a string"
let anArrayOfStuff = [someObject,anotherObject,yetAnotherObject]
As for everything acting like an object, that's a good thing. objc strings were already that way, why have the duality between a scalar '5' and an NSNumber '5'? In fact, that duality can get you into trouble:
if( myObject.someNumber ) …
If you forget that someNumber is an NSNumber and not a scalar, this will run just fine but not have the intended effect. In Swift, this would never happen.
Mike
> On Jun 3, 2014, at 8:14 AM, Gordon Apple <email@hidden> wrote:
>
> My response was “Oh, no! 567 pages (iPad Retina portrait mode) of more s*** I have to learn.” One of the main advantages of Objective-C was that it was loosely typed. Now, it looks like we’re going back to a strongly typed language, nested functions (a la Pascal), everything is (or at least acts like) an object, etc. I’m not at the conference, so I’m hoping the vids will expound on the rational for this highly disruptive change and show where it really buys us an advantage.
>
>
> On 6/3/14 9:18 AM, "email@hidden" <email@hidden> wrote:
>
>> I can't comment yet, I just haven't read far enough and tried it out to see if it replaces enough of ObjC for it to be a replacement. You still need C down there somewhere at the least. I need to find the Swift-interface-C chapter. And if it does, I *still* don't know why. ObjC is an ok language, it does what it does, you learn it, you use it. On 3 Jun, 2014, at 10:08 pm, Akis Kesoglou <email@hidden> wrote: > On 3 Ιουν 2014, at 17:03, Roland King <email@hidden> wrote: > >> ... With some ObjC thrown in there too with the named/typed parameters. ... > > And that's exactly the reason I see ObjC being deprecated. From what I've read, Swift *feels* a lot like ObjC -- init/dealloc, designated initialisers, named function arguments, ARC, verbosity, etc. > > Akis >
>
> _______________________________________________
> 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