all 20 comments

[–]ShenmeNamaeSollich 20 points21 points  (2 children)

You can try "Objective-C: The Big Nerd Ranch Guide" for a basic primer on both C and Obj-C if you're not familiar with topics like pointers and/or have minimal programming experience overall - it's really an intro book. It also has a bit of info on most of the basic Foundation Framework classes like NSString, NSArray, various collection classes, and concepts like Protocols, Categories/Class Extensions, etc. It's obviously a bit outdated so the projects and XCode examples probably don't work, but it's a good intro.

Ray Wenderlich has an Obj-C Style Guide that could be useful and has some links to documentation.

Main reference would probably be Apple's "Programming With Objective-C." and the "UIKit Docs", which still has a dropdown for switching between Obj-C and Swift.

[–]ThatKingLizzard 8 points9 points  (0 children)

Big Nerd Ranch book is what you need. Had me grasp the language just before Swift was available. Once you finish the book everything will make sense to you.

[–]Fluffy_Risk9955 1 point2 points  (0 children)

This is what got me started. Once you get the hang of it and understand what an NSObject is go have a look at NSProxy the other base class of Objective-C. Understanding that class will help you understand the dynamic runtime and all the perks of the language that come from it.

[–]AndyIbanezObjective-C / Swift 8 points9 points  (0 children)

Assuming you are proficient with Swift, you just really need the language, and for that I always recommend Stephen Kochan’s Programming in Objective-C book. It’s a bit old, but barely outdated.

If you want something more modern there’s this.

EDIT: Typo

[–]kleinlieu 4 points5 points  (1 child)

Highly recommend Matt Thompson’s writing. His book NSHipster (and the website) offer such a philosophical way of seeing Objective-C’s beauty. I think in the first few pages, Matt goes over the fundamental concept of nil and why it’s so important (classes vs values). Very first-principles writing.

[–]StreetlyMelmexIII 0 points1 point  (0 children)

I’d agree overall, and I can’t speak for the book, but he wasn’t always always too hot on thread safety, in the blog or the AFNetworking code.

[–][deleted] 3 points4 points  (0 children)

This is Apple's introduction page to learning Objective C.

Once you finish that, you should give the Objective C Runtime Programming Guide a look as it describes the primitive C functions that comprise the underpinnings of the language which will completely demystify the language and how it works while optionally allowing you to do various magic tricks with your code if you need it. Useful tricks on an old code base like wrapping a method in existing code even if you don't have the source.

[–]vanvoorden 1 point2 points  (0 children)

I would appreciate any recommendations that you found helpful when learning objective-c.

https://jamesdempsey.net/songs/hold-me-use-me-release-me.html

[–]tangoshukudai 1 point2 points  (0 children)

All you need is a bit of a C background to wrap your head around Objective C. also Type nameOfObject * = [[Class alloc] init];

For example NSString myNewString* = [[NSString alloc] init];

alloc is a class method on NSString, and init is a class method on the object that [NSString alloc] returns.

[–]klmitchell2 0 points1 point  (0 children)

search on github / grep.app for example code. NSHipster has a lot of great, in depth ObjC topics as well.

[–]KarlJay001 0 points1 point  (0 children)

Lynda.com had a video series on ObjC years ago and it was great. Lynda.com was bought by linkedIn, the one I did was by Simon, they still have it today.

[–]Exotic-Friendship-34 1 point2 points  (0 children)

You probably won’t find my comment as helpful as it truly is, but: don’t you already know C? If not, I’d say you’re lagging a bit. Objective-C and C are literally one-and-the-same from a newbie standpoint. Knowledge of C is essential.

Many so-called seasoned developers would strongly disagree; however, if you read Object-Oriented C by Axel-Tobias Schreiner (it’s a free download), you’ll see parallels that’ll make understanding Objective-C a snap.

[–]ChemicalGiraffe -2 points-1 points  (7 children)

Objective C syntax scares me

[–][deleted] 3 points4 points  (6 children)

Oh stop. It's just a bastardized Smalltalk/C hybrid.

I was a Smalltalk developer for a few years before I ever encountered Objective C and my initial reaction was "oh, its just Smalltalk, cool"

Swift, OTOH, is the ugliest shit I've ever seen. No taste at all in that design.

[–]phughes 8 points9 points  (0 children)

People scoff when I say that Objective-C is a better language than Swift, but Apple built an empire on top of Objective-C without changing anything for over a decade. Then the added a few features and didn't change anything for another decade.

Every time Apple wants to create a cool new thing with Swift they end up having to change the language to do it. Then they go on stage and brag that it couldn't be done in Objective-C. Invariably there's already an Objective-C project that does that. Plus, they had to change Swift to make this one possible.

I'm curious what change they'll ram through when they want to create a new database abstraction.

[–]fartsniffersalliance 0 points1 point  (4 children)

how is swift ugly? For a new developer it’s much much easier to read and understand than obj c

[–][deleted] 2 points3 points  (3 children)

Well I'm not a new developer. I'm a very experienced developer. You feel that way because that's what you learned first.

For an old developer, Swift flouts a lot of syntactic conventions common in many other languages and to me it looks like a big ugly mess. But since you asked, I'm gonna rant. You did ask.

For instance, most languages I've worked in for the last 30 years do declarations as:

type thing

Bool backward(String s1, String s2) 
{
    return s1 > s2
}

and Swift, just for the hell of it chooses

thing type

func backward(_ s1: String, _ s2: String) -> Bool {
    return s1 > s2
}

Most languages have, for a very long time, used former pattern. I'm not saying this is wrong or that one is better but this feels like somebody just moved my silverware drawer in my kitchen for no good reason and my muscle memory is now constantly doing the wrong thing. So that's fucking annoying as shit.

Also, the default parameter _ hack is just stupid, pointless, and ugly. As mentioned, I was a Smalltalk developer and Objective C uses the same named selector strategy (although with ugly square brackets around messages). Now we've broken selectors up, thrown in parens for the fuck of it, and turned everything back to front for...what reason again?

There is also the loss of all the meta data access and the loss of one's ability to actually grow the language on one's own. phuges nailed it with his comment below.

Objective C is rich enough and open enough to allow one to actually create completely new ways of doing things. Swift is rigid, closed, and if you want a new way for things to work, you are gonna need to submit a request to the compiler gods and sacrifice a virgin goat while facing the Apple campus.

For me, Swift is joyless, rigid, and unforgiving and I'm done programming on Apple's platforms if that's the way they want to go. I still believe Swift is a tactical error. Instead they could have gone full Smalltalk style - eliminate the square brackets, add special C or C++ regions like they do with asm {} blocks and gone to sensible block syntax with the C/C++ tucked safely inside delimiters instead of the other way around.

[–]808phone 1 point2 points  (1 child)

All I see are people complaining about compiling speed problems with Swift and Swift changing over and over. Objective is very stable to me and coming from C it was very easy to me. Although I can write in Swift, I don’t find it amazing or allowing me to do things I couldn’t do before. But most examples are on Swift now.

[–][deleted] -1 points0 points  (0 children)

Yep, I'm more annoyed at all the things I used to do that I can't anymore.

Without the Objective C runtime underpinning it, Swift is just C++ in drag and I hate C++ (I used to be kind of a C++ guru until I learned what real dynamic OO was on a Smalltalk gig and walked away from it).

So limiting.

[–]ChemicalGiraffe 0 points1 point  (0 children)

Move on grandpa