
Hello, dear readers of Habrahabr!
The team of incoherent development managed to get a corporate account thanks to Habrahabr’s miraculous program to support start-up startups without effective monetization. We are the guys who often arrange the broadcast development of
various applications for 24 and 48 hours . Today, we have embarked on the creation of free analogues of the necessary, but paid or advertising-hung programs.
So that our welcome post doesn’t turn out “About nothing”, today
I ’ll tell you about some goodies from working with Xcode 5, spy on
iOS 7 Tech Talks . In the program of the evening:
')
- Autocompletion of the code: cookies that have not been tried yet
- Edit in scope: nourishing chocolate cake
- Objects IB: name this variety of strawberry jelly
- Double status bar: serve chocolate shake chilled
- Color Blended Layers: you put rum cream on wrong
- Concurrent Object Enumeration: Cover All With Icing Sugar
- Localization: stop heating the oven every time

Code completion
And so, you have been friends with Xcode for more than five years and think you know everything about it? And what if I say that it is not necessary to prescribe the return type to initialize code autocompletion? Forget about:

Now you can write like this:

Edit in scope
Suppose we have a simple method that does not pretend to any intellectual significance:

The error is visible even to a novice programmer: we created a new variable
number in the line of sight of an already existing variable with the same name. You can, of course, change all titles with pens. And what if laziness? And what if there is no time? But you can use Cmd + F! No, no and NO. Now you can hover over a variable and see a small triangle next to it:

By clicking on this icon, we will invoke the context menu with the cherished "Edit All in Scope":

Here is how it looks in real time:

And for fans of hot keys there is a separate combination (Cmd + Control + E):

IB Objects
I often know about other people's code of duty, and in particular, with other people's Storyboards. In some interfaces collected by previous developers, the devil will break his leg. I want to play a game with you: where is the UIView?

Suddenly? But this situation can be easily corrected! After all, all interface elements can be called as you like. Please adhere to good tone and think about future developers. Maybe someday, the good will come back to you:

Dual status bar
Speak, does your application work perfectly? Is it 99.9% covered with tests, and did you even correct a couple of critical bugs in the Foundation? And what happens if the user gets a call? Fortunately, we have an easy way to check. The simulator supports the display of "extended" bar status when calling:


To properly handle incoming call events and bar status extensions, you can either start listening to NSNotificationCenter:
UIApplicationWillChangeStatusBarFrameNotification UIApplicationDidChangeStatusBarFrameNotification
Or implement the following methods in your AppDelegate:
- (void)application:(UIApplication *)applicationwillChangeStatusBarFrame:(CGRect)newStatusBarFrame; - (void)application:(UIApplication *)applicationdidChangeStatusBarFrame:(CGRect)oldStatusBarFrame;
Color Blended Layers
It is obvious to everyone who is close to programming that drawing transparent objects is more difficult than processing opaque ones. At a minimum, the device needs to think about the background and spend time drawing it. However, many programmers neglect, and some do not even know how the “opaque” (opaque) property is translated. Better not to do that.
For example, take the usual white UITableView and turn on the Color Blended Layers:


The red simulator shows elements with active alpha channel, green - opaque elements. Unfortunately, the processor is now spending extra time drawing the white background behind the transparent text. This is solved quite simply, with two actions in Xcode - tick the “Opaque” checkbox and make the background white:

After that, everything looks much nicer to the eye:

It is worth noting that if you use a picture with an alpha channel in your application, then ticking "Opaque" will not be enough. Xcode respects your transparent pictures (especially if these are kittens pictures), and even if you tell him that a picture without transparency - in other words, fool him - he will still do it by honor and make the picture transparent. When you need to make a picture opaque - do it in some graphic editor. Xcode will be able to process the image as opaque, only when the image does not have an active alpha channel.

Concurrent object enumeration
All I want to show you at this point is the next couple of lines of code:
NSArray *myObjects = ...; [myObjects enumerateObjectsWithOptions:NSEnumerationConcurrent usingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
Special attention should be paid to the property that we pass to the method:
"NSEnumerationConcurrent" . It allows you to use all the advantages of multi-threaded programming when working with an array of data, without bothering with GCD or NSOperation.
Localization
If you ever translated your application into other languages, then you are familiar with this pain with the constant change of language settings in the simulator. Just look at this mess:

No, that will not do. But what if you just need to fix a minor bug in one of the locales? Switching back and forth is time consuming. There is a simpler, faster, smarter solution! You can create several different schemes for the build, so that each scheme has its own language. Go to the settings of the main scheme:

Click "Duplicate Scheme":

B add two flags:
"-AppleLanguages (ru)" and
"-AppleLocale ru_RU" (the names of the locales should google if you don't remember):

Now we can instantly launch our application in different languages, without entering the settings of the simulator:


Conclusion
Thank you so much for reading to the end!
I will try to post more often different interesting things from the WWDC and other conferences on Habr: sometimes it is easier to spend 10 minutes to read the text than 40 minutes to listen to Tech Talk with the same amount of information. However, I highly insist that every iOS developer watch at least 2-3 videos from these conferences for self-education.
By the way, there are rumors that the next broadcast will be at Christmas (December 25) and we will try to create a “killer clone” of paid applications like “Heads Up” from the App Store. Naturally, with Russian localization.
Here we are - the team of Talking Development: with a cloud of pictures, gifs and kittens.
PS If you find a mistake or typo in the text - be sure to write in
my habracenter .