If you manually create a parent and child relationship between two view controllers, the child view controller might not have a navigation bar in this case. So you might be wondered why the navigation item of the child view controller doesn’t effect on the navigation bar. But you need to understand that the navigation bar on the child view controller is not the child view controller’s navigation bar. Because the child view controller is embedded into the parent view controller. So you need to create a LeftBarButtonItem on the parent’s navigation bar and customize the button with a target and an action pattern in the parent view controller.
11/16/2016
Wait unitil a loop with asynchronous tasks finishes executing
2:27 PM
dispatch, dispatch_group, GCD, loop, Swift, thread
No comments
A completion Handler in iOS takes a thread to asynchronously get it done. So it means that we can’t know an exact point which the tasks finish. For example, if we use a for loop to execute several tasks in the background, how could we know all the task are done?
In this case you can use dispatch_group.
- Create a dispatch group which graps all the tasks in a for loop with
dispatch_group_create(). - You point out a position which your code enters the dispatch group with
dispatch_group_enter(groupname). - You point out a position which your code leave the dispatch group with
dispatch_group_leave(groupname). - Lastly you can get a notification when all the tasks you assigned to a dispatch group is done with
dispatch_group_notify.
If you want to see a concrete example for it, please refer this.
9/10/2016
Activate Firebase without Cocoapods in Xcode 8
So I should do it manually without CocoaPods.
Deintegrate Cococapods from a project
First of all , I need to clearly deintegrate Cocoapods from my project.I found this. And I can clearly remove Cocoapods from my project.
FireBase integration
The problem that I faced is a overwhelming Link errors below.I need to add several libraries to use Firebase in Xcode 8 and iOS10.
- SystemConfiguration.framework
- libc++.tbd
- libsqlite3.tbd
- libicucore.dylib
8/30/2016
Simple Migration Options for CoreData PersistentStoreCoordinator
1:46 PM
CoreData, Migration, PersistentStoreCoordinator
No comments
If you change a scheme of your CoreData such as adding a new attribute, you can easily migrate it with options below.
do {
try persistentStoreCoordinator.addPersistentStoreWithType(NSSQLiteStoreType, configuration: nil, URL: storeURL, options: [NSMigratePersistentStoresAutomaticallyOption: true , NSInferMappingModelAutomaticallyOption: true])
} catch {
fatalError("Error migrating store: \(error)")
}
8/29/2016
New Fitbit Flex 2 , Fitbit Charge 2 and Apple Watch 2
4:58 PM
Apple Watch 2, AppleWatch, Fitbit charge 2, New Fitbit Flex 2
No comments
Fitbit Flex 2
Fitbit launched Fitbit Flex 2 which put a new function to track a swimming activity. It is similar to Misfit Shine.
Tracking a swimming activity
It tracks…
- Laps
- Duration
- Calories
- Distance
If it is compared to Misfit Shine’s Swimmer’s edition, Misfit Shine tracks everything which Fitbit Flex2 supports.
I think that Misfit Shine is more customized to track a swimming activity. Misfit Shine supports a unique feature calling ‘Swim Time Countdown’.
Water Resistance
Both of them support 50 meters water resistance.
Fitbit Charge 2
Several features which you should notice.
- Improved its heart rate sensor.
- Multi-Sports mode: tracks specific exercises like running , weights or yoga.
- SmartTrack: Automatically records select exercises like hiking , biking , sports and more. Interested in experiecing how it works.
Fitbit VS Apple Watch 2
Now I wonder that the upcoming Apple Watch 2 supports more tracking features which Fitbit leads with their new products.
8/21/2016
How can I use San Francisco mono font in Xcode7 ?
Apple released a new coding font which calls San Francisco mono. I have used Source Code Pro which Adobe created. But I would like to test and use Apple’s one in Xcode7.
Basically San Francisco mono font is pre-installed in Xcode8 beta. So here is the way to use it in Xcode7.
Install Xcode8 and find the location of the font.
Copy them into your font directory in macOS. I used ~/Library/Fonts
Launch Xcode7 and configure it as a coding font. (Xcode7 has a bug that you can’t select font collections in your macOS system. If you meet the problem, run the command below in Terminal and try it again.)
defaults write -app Xcode NSFontPanelAttributes -string "1, 0"
8/15/2016
Why did I get the result nil through dataTaskWithURL ?
3:54 PM
dataTaskWithURL, iOS Networking, NSURLSession
No comments
If you use dataTaskWithURL , your intention might be getting a data from server and display the data to your UI. But, sometimes it makes a problem that the resulted data is nil.
To solve this issue, first of all you must recognize that dataTaskWithURL runs asynchronously. Conversely UI stuffs runs on the main thread on iOS. So the time that you get a data from the server might not be synced with the time you display the data to your UI. So in this case you might see a strange nil value on it.
You can simply think that I can run it sychronously. But, it would cause a bad user experience. So here is a solution which is creating another completionHandler to run it asynchronously. And then if you want to update your UI , remember that the task should be taken on main queue.
