I’m pretty sure everyone of us that uses iOS always has a wishlist for the upcoming version. I’ll keep mine simple. Those are the top 8 things that I wish to have in iOS 7.
- Better sharing between apps (hint: Android)
- Ability to set default apps
- A better email app
- A better camera app
- Quick access to settings like turning on/off Wi-Fi & Bluetooth, changing brightness, etc…
- More options for organizing home screens
- Automatic app updates
What are yours?
NSURLCache can be used to define memory and disk caching for URL requests. If you make a connection while you are not connected to the internet with the cache policy set to NSURLRequestReturnCacheDataElseLoad, data should be returned from the cache if it exists. This works as expected on iOS 5 and cached data is always returned. On iOS 6.x, however, this doesn’t happen and the connection will fail returning an error code -1009 which indicates that you are offline. I ran into this recently while using AFNetworking and apparently this is a bug in iOS 6.x and has already been reported to Apple by multiple people.
To workaround this, I wrote a simple class that subclasses AFNetworking‘s AFHTTPClient (thanks to this GitHub issue) and ensures that you always get cached data when it’s available regardless of whether you are connected to the internet or not.
What it does is that it gets the NSCachedURLResponse in the failure block of the request you are making and deserializes it using NSJSONSerialization, then calls the success block with the responseObject as if the connection didn’t fail.
I’ve added the code to a GitHub gist. Please fork it if you think there’s something that could be improved.
I wrote a streaming app for NileFM a while ago but it never got accepted into the App Store.
I’ve placed the code on GitHub which serves as a good tutorial for streaming apps that uses MPMoviePlayerController or even a starting point for a more complex app.
Check the repo on GitHub: https://github.com/HeshamMegid/NileFM
I needed a way to transform all the properties of an object that are not nil into an NSDictionary. I didn’t find a quick way to do it so I wrote my own NSObject category.
It uses the Objective-C runtime and the idea is really simple. I get a list of properties of the object’s class, loop on them getting their value, and only add them to the dictionary if they are not nil.
Introducing HMSegmentedControl, a drop-in replacement for UISegmentedControl mimicking the style of the segmented control used in Google Currents for iOS.
Grab the code from GitHub: https://github.com/HeshamMegid/HMSegmentedControl
The code on GitHub includes a demo project showing how to use the control.
To use in your own project, first import HMSegmentedControl.m and HMSegmentedControl.h into your project, then add QuartzCore to your linked libraries.
The code below will create a segmented control with the default looks:
HMSegmentedControl *segmentedControl = [[HMSegmentedControl alloc] initWithSectionTitles:@[@"One", @"Two", @"Three"]];
[segmentedControl setFrame:CGRectMake(10, 10, 300, 60)];
[segmentedControl addTarget:self action:@selector(segmentedControlChangedValue:) forControlEvents:UIControlEventValueChanged];
If you used this code in your project or it was helpful to you, I would love to hear from you!
In an app I’m working on, users are supposed to enter their phone number including the international dialling code. I know this could be confusing for some users that are not so sure about the dialling code so I wanted to insert it automatically.
So I’ve created HMDiallingCode, a light weigh library that gets the dialling code of the user’s current location. It uses CoreLocation and reverse geocoding to determine the country of the user, then retrieve it’s international dialling code from a plist.
The code is available on GitHub at https://github.com/HeshamMegid/HMDiallingCode