文章出处,原创于 https://HawkingOuYang.github.io/
Xcode7 _Nullable 和 _Nonnull
StackOverflow 英文资料:
Difference between nullable, __nullable and _Nullable in Objective-C (这个好)
Apple 英文资料:
Nullability and Objective-C
Using Swift with Cocoa and Objective-C (Swift 2.1)
Swift and Objective-C in the Same Project
quora: Should I learn Swift now instead of Objective-C if I want to become an iOS developer?
Q:
I am planning to spend the summer learning iOS development, but with the announcement of Swift I’m not sure whether I should still focus on Obj-C or skip over it and start learning app development with Swift. Is Obj-C a necessary foundation for Swift?
A:
Learn Objective-C for now.
As someone who already knows Objective-C, I spent a week or so writing an app in Swift and reading the Swift e-book Apple released (which is really good). Swift is a nice language. But there are a couple of reasons I ended up rewriting everything in Objective-C:
You’ll be translating Objective-C. Apple’s docs, every tutorial and book out there, and every StackOverflow answer has code in Objective-C that you’ll have to translate if you want to use it in Swift.
There are kinks. Xcode 6 Beta is quite buggy. There are also weird issues with autocomplete and syntax highlighting. This is the last thing you want to have to deal with as a beginner.
Swift may change in the future. The Swift developers have stated they may change Swift syntax/behavior in the future (which would break your code). There’s already a list of changes that have been made to Swift in just the past few months.
That being said, I believe Swift will replace Objective-C in a few years.
A:
Joe Burgess, iOS Instructor at The Flatiron… (more)
95 upvotes by John Li, Amanda Himmelstoss, Victoria Friedman, (more)
In short, no. Every current code base is going to be objective-c. Every current third-party library is objective-c. You don’t need to know obj-c to learn swift but it’ll help a lot. Knowing objective-c is going to be crucial for at least the next six months to a year. You will always come up with ways to delay learning something. Take Swift out of the equation.
Thankfully, learning objective-c is going to help you immensely with Swift. Much of iOS programming is simply learning the frameworks. Even though the syntax changes from Obj-C to Swift, the properties, methods and everything else about these frameworks is consistent. Last, most of the learning materials for Swift assume you know objective-c already and there are purposefully many parallels between objective-c and swift. Learn Objective-C, then when you need to, learn swift. It’s going to be pretty darn easy to learn that second language.
Learn Objective-C now. If you want some help with objective-c, I put together some resources at Flatiron School Pre-work for my class at The Flatiron School. Hopefully, they’ll help you out.
A:
Stan Idesis, Android Director at Bloc.io
13 upvotes by Willem Schouten, Joey Kirk, Prasid Pathak, (more)
I recommend both. There will be a need for Objective-C developers for quite some time, likely for the next two years at least. Every existing iOS and OS X application is written in Objective-C and if you were to join a team with an existing project, they would have you continue to work in Objective-C.
However, this transitionary period will involve the slow-but-steady conversion from Obj-C to Swift and therefore developers knowledgeable in both will be in demand for the meantime.
Knowing iOS is important though. Its APIs, terminology, Xcode, etc. are all vital aspects which are required regardless of which language you choose.
At Bloc, we teach both. Check out our iOS Program to learn more.
A:
Gregory Raiz, I started Raizlabs a leader in… (more)
7 upvotes by Ashish Pawar, Willem Schouten, Pantelis Zirinis, (more)
Do you want a job today or in two years? Learning objective-C will give you a highly marketable skill today. Learning Swift will give you a highly marketable skill in two years.
You can’t currently get away with knowing just Swift and not objective-C and it will be at least two years until this is possible. The existing code-bases and open source projects are mostly Obj-C and all the Apple frameworks and most of their examples are also Obj-C.
I expect that it will take about two years before there will be a legitimate market for developers who only know Swift. I would add that even two years from now a developer who knows both will be more valuable to most organizations.
First off—avoid the mindset that you must learn any one language over another. There is no one language that takes you to the holy land. Languages simply just “are”, and each serves its own purpose.
Having said that, Swift doesn’t replace Objective-C, not yet anyway. It’s a new language Apple/Chris Lattner created that allows for a new style of app development. If iOS programming is your goal, I would learn Objective-C, and then learn Swift.
Keep in mind since you’re new to iOS, you will greatly benefit from the maturity of Objective-C and the size of the community, the amount of Stack Overflow answers, and support networks you can turn to—which will keep you motivated and put you in a better spot to learn Swift having already had some iOS development under your belt. Swift will surely be awesome, but aside from Apple’s Swift’s programming guide, you will more or less be on your own, left to encounter the “gotchas” and uncover the documentation mistakes on your own. That is not to knock Swift—it’s just the natural order of new technologies. They all go through that.
Don’t buy the hype that just because something new comes out you have to solely focus on that. Learn everything. Don’t box yourself in. You’re not joining one club or another. Painters learn to use different brushes. Programmers learn many languages. It’s more valuable to understand the value in each than to limit yourself to one way of thinking.
Apple chose Objective-C first, and then arrived at Swift. Perhaps follow the same path and you’ll gain an intrinsic understanding of why, which is far more valuable long-term.