How does one solve this, in a way that the user isn’t easily confused. You could just write out the hole date, but there isn’t always room for that in you interface.
Well luckily Apple has made it easy for you to present a date in some format (small, medium, large and full) that the user will understand. This is because the date are represented in the user local format. No longer will your user be confused by date if you use the default format style for you date representation.
So lest start:
NSDateFormatter* dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setTimeStyle:NSDateFormatterShortStyle];
[dateFormatter setDateStyle:NSDateFormatterNoStyle];
NSString *dateString = [dateFormatter stringFromDate:someDate];
Well that look really simple right and it is, the date will now be formatted with the users localization settings.
Let’s say that the someDate is 1 januari 2014 13:00 GMT, lets see how it looks
US style 1:00 PM
Most European styles 13:00
Keep in mind that allocing a object takes time and in this case 4 lines of code, luckily Apple even thought about this and there is a shorter way of doing it:
NSString *dateString = [NSDateFormatter localizedStringFromDate:someDate
dateStyle:NSDateFormatterNoStyle
timeStyle:NSDateFormatterShortStyle];
Here are some example of the styles on my system, using a US locale:
Short: 12/1/14, 2:00 PM
Medium: Dec 1, 2014, 2:00:00 PM
Long: December 1, 2014 at 2:00:00 PM GMT+1
Full: Monday, December 1, 2014 at 2:00:00 PM Central European Standard Time
Parsing is where things become difficult, as many post on stack overflow will tell you. Most of which are about localized dates.
Localized dates are not very useful on the internet, since it is international and localized date can be mis interpreted. For some weird reason some API will have localized date instead of a ISO or RFC standaard date. Lets see an example:
sun 1 december 2013 2:00 PM
Well this is difficult to parse, since the system will need to know the language is which the date is presented. So we will have to tell the NSDateFormatter the language used, which is identified by it locale:
NSString *dateToParse = @"sun 1 december 2013 2:00 PM";
NSDateFormatter* dateFormatter = [[NSDateFormatter alloc] init];
dateFormatter.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"];
dateFormatter.dateFormat = @"EE d MMMM yyyy h:mm a";
NSDate *date = [dateFormatter dateFromString:dateToParse];
In this example you can clearly see that the date is localized, so we tell the date formatter that it locale that is used is english. The date formatter will now understand that the date contains english words.
Please always set the locale is you are parsing localized dates, because if the localized date does not match the systems locale the parsing will fail.
You will find a full list of unicode date time format code here: http://www.unicode.org/reports/tr35/tr35-25.html#Date_Field_Symbol_Table
Now a detail about NSDate, NSDate does not know anything about timezones. It is always GMT. Thus when you run the above code the time might off. It is not really off but the the time is offset to the users timezone.
When parsing the date, without any time zone, the users time zone is used. If we run the example above and print the date you could and up with
2014-12-01 13:00:00 +0000
This is because my systems time zone is +0100.
]]>if ([[[UIDevice currentDevice]systemVersion]floatValue]<5.0) {
[self presentModalViewController:errorView animated:YES];
} else {
[self presentViewController:errorView animated:YES completion:nil];
}
In this example you’ll see that the system version is casted to a float and checked where it is lower than 5.0.
This might look like a great check, but it is not! In the example you are assuming that all device system versions will be the same, which they are note. For example the Apple TV, it is also running iOS and currently running version 6 of it operating system, which based on iOS 7. So a device check of the system version will fail for an app running on both system. (lets just assume that you could build app for the Apple tv for the sake of this example).
The solution is very simple, just check if the new method is available.
if ([self respondsToSelector:@selector(presentViewController:animated:completion:)]) {
[self presentViewController:errorView animated:YES completion:nil];
} else {
[self presentModalViewController:errorView animated:YES];
}
No this code is more future proof than the pervious one, because you are just checking wether the method is available.
If you want to use a class which is not available in a previous version of the SDK you can also easily do a check if the class method returns a value:
if ([MKMapCamera class]) {
// Go ahead and use the class.
}
When there is no option to check the class or method existence you should check the foundation version. The foundation version is the version of the underlying API (Foundation/SDK version). Apple gives a great example for this in there iOS 7 transition guide:
if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1) {
// Load resources for iOS 6.1 or earlier
} else {
// Load resources for iOS 7 or later
}
This is the only correct way of checking the system version. System version is not correct in this context., you really look to the API (Foundation/SDK) version.
No let us talk about different devices, for a universal App you will need to support 3,5”, 4” and iPad devices.
Apple made it very easy for a developer to load device specific resources, they call this device modifiers. There are now too known device modifiers: ~ipad and ~iphone. They work almost the same as the @2x modifier for images.
Let us have look at the following example, you will find this as one of the many answer on stack overflow.
MyViewController *viewController = nil;
if (UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPhone) {
viewController = [[MyViewController alloc] initWithNibName:@"MyViewController" bundle:nil];
} else {
viewController= [[MyViewController alloc] initWithNibName:@“MyViewController_ipad" bundle:nil];
}
You see the conditional loading of the view (NIB) based on the device idiom, this can replaced by one line. Just be sure that the file names are correct. The iPhone version of the NIB can be MyViewController.xib
and the iPad version should then be MyViewController~ipad.xib
. Then just create your view controller like you normally would.
MyViewController *viewController = [[MyViewController alloc] initWithNibName:@"MyViewController" bundle:nil];
This will also work for storyboards and images.
Your app should also support both the 3,5” and 4” iOS devices. This can easily be done by using autolayout to adjust you UI to match the height of the screen. But even without autolayout can make you UI grow to fill the screen. Just be sure that you set the correct auto resize mask in interface builder.
Utilising these techniques will save you a lot of work and making debugger your app easier.
]]>
My interest in computer did not start until I was around 16, before that I was just using computer for gaming. Which I played mostly at friends’ house since we did not get new computer until 1997 that was able to run the games I liked. When we got a new Pentium 166 MXX and Windows. This was a huge step forward from the old dos machine we had before. Soon after getting this machine I bought my first own machine, a second-hand 386, which I pimped the hell out off. Added an sound card, CD-rom player and even got it to boot Windows 95.
Then for my 18 birthday I got a new machine, a nice Windows machine which really changed my live. I started programming, first in Visual Basic and later in Delphi.
Around that time all the old machines were still in my room and we were playing games via a LAN networks. A friend of mine had an old Mac which I got when they switch to Windows, the machine had a Apple Portrait Display, sorta like a wide screen but then in the vertically. It came without any Operating system disk and was my first go at mac OS 7. Because it was lacking any operating disks I could not restore the machine and it booted with error about missing system files. Eventually I sold the machine to someone who was interested in the monitor. After that I got one of the first iMacs, blue of course.
I did not do anything with the Mac until after graduation. At college (HBO) I started using Linux because it allowed to me to tweak my system, liking the unix like OS I was always feeling a bit handicapped in Windows. Seeing that some of my classmates bought MacBooks around this time, I was once again interested in Macs. I liked the fact that they just pulled their notebook from their bags and start working on them, no booting and a standby mode that worked.
After graduating and getting a job a C# developer I did not think long about buying a new machine for long. At this point the first Apple iPhone was introduced and talk about Android started. I was really interested in getting an Android phone at that time, since it was running Linux. A system that I knew and liked. So I downloaded the development kit and arrrrggg java. No this could not be right. I really dislike Java as programming language because of it structure. At the same time I was also looking for a new notebook and a friend bought a MacBook a year before. He showed me how his new MacBook was doing about 4 hours on battery and could run Windows, if you really needed it. So that was it then I order a black MacBook.
Soon after getting my shining new MacBook the iPhone 3G was available for sale in the Netherlands and also the T-Mobile G1. I was lucky enough to get my hand on both devices, because colleagues had got them, my first reaction was “wow the iPhone is fast”. The T-Mobile G1 felt like a piece of plastic that was about the break, let alone that the operation system did not feel very finished.
Since I could renew my contract about that time I ordered an iPhone, moving away from my idea of getting an Android phone. I received the my iPhone not much later with an unlimited mobile data subscription, wow those where the days.
Not soon after I started to code some small apps in Objective-C, which really took some getting used to coming from a C# background. But I loved the memory management language since it allowed me so much control.
The company that I then worked for had some big clients. One of them was really interested in getting an app in the AppStore. They wanted a radio streamer, which I happened have build myself because I liked to listen Zeilsteen. This radio stream for this client became my first ever released App, just before Zeilsteen.
]]>But no, these courses will teach you how to use the iOS (or Andriod) SDK for a really simple task. At the end of the week everyone is happy and the students are really proud of the App.
Now some of these student got enrolled in the class because they had an idea for a great app. After following the course they retreat to their small desk at home to start coding away on there first great app.
And soon they discover that developing the app is not as easy as the course let them to believe and they start to search on the internet for answers. Often ending up on stackoverflow, where they will just post the question as if it was a code request.
Now most of the new developers will make their greatest mistake of there early career:
post a question describing some requirements that are way to broad or to complex for even junior programmers to understand. And their question is closed, bashed or laughed at by the user of the website.
Don’t let it discourage you, some of them are willing to help. Just break down your question in smaller parts or start simpler.
The thing is, programming for any platform is not something you can learn by just doing some course for a week. Sure you will know some of the components that the framework supplies you with and you will be able to build a simple app.
But in noway are you there, you will need to learn more. Start by learning how to debug your own software, with breakpoints and use the power of the debugger. If you are developing in higher languages, the platforms garbage collector will help you clean up memory, but in lower languages you will have to do this yours self. So read the platforms memory management documentation and stick to it’s rules. Next start learning about software patterns, something most frameworks are full of.
If after al this you still find it to hard then maybe programming is not your thing. But your idea might still be a very good one! Just contact a developer tell them about your idea and they might just be willing to help you realize that great idea into a great app. If you are worried about the developer stealing your idea you can have them sign a contract, there are some good ones around on the internet:NewAppIdea.com sample NDA.
Just keep in mind that being a developer is a profession, not something everyone can do. Most of use studied for many years to get where we are today. I would probably not be able to do your job. But if you are willing to try real hard and put in many hours of studying, you might be able to get that one gem of an app in the AppStore.
]]>Many companies have the idea that they really need an app to get in to other markets and young people, and tahts not a bad idea.
But just wanting an app because every one has one is not the best way of going at it.
I’ve made some iOS apps that where just that, a one time fun app or even just a flyer kind of app. Some of which never made it to the AppStore, because Apple said that they had no added value and should just be an mobile website.
And guess what, there right.
There is no need to just get an app just because it hip and happening, its should be adding to the user experience. I’ve you want to be on the mobile market you could just as easily just create a beautiful mobile site.
Apps should added something that the user will use more then once and makes him/her want to use it more often.
Lets have a look at an app that is just there because they could, this is of course my one opinion.
Ikea has an app in the app store to allow you to view the catalogue. Which a great idea, but the app disappoints.
First you download the app, then you need to download the catalogue, which take al long long time.
Then you see that the app is just the paper version but then on your phone.
It does have nice store locator, which show you the nearest store. Which the maps app could have told me.
I understand that the power of Ikea is the fact the you always buy more stuff then you need. They really try to get you in to there stores.
Now here is something they should have build in there app: Have you every used those little pencils and shopping list.
Well the system works, but if you are like me and have a terrible handwriting than you just use the camera on you phone to make a picture of the location in the magazine.
But what if there was an app, made by Ikea, that when I scan the barcode of the product it would add it to a digital shopping list?
They could easily build this, the barcode are already on the labels. Then just and a map of the magazine for the location and you can find your stuff.
There is also a nice possibly here to do some up selling, when you scan an article that requires an other article the app could suggest that to you.
Appie is probably one of the best Dutch apps. This supermarket made an app that does more then just be a digital shopping list. Well sorta.
They have all there products listed in the app and will order your shopping list in order of which they can be found.
A new feature is the sync with a shopping list online, now if only you could allow people form your household and push products to the app that would be great. It’s features like these that make the app great.
One being also keep in mind that you may have to translate your app.
I tent to use NSLocalizedString for every string I write in code just so that when its needed I can easily translate the app. Which has been a time saver many times.
I don’t really use the multilingual NIB (adding localised versions of NIB files). Because, especially in early stage if development, you have to maintain two or more files. I just do it in code and adjust the UI if needed.
Getting the size of a string is fast en easy.
The following this have changed:
+ Full background playing. (Yes it does work this time)
+ Library with latest played songs, and album images if available.
+ Currently playing information on Lock screen (iOS 5).
+ Twitter and Facebook integration, brag about the great songs on Zeilsteen.
Go to the organizer (⇧⌘ 1) and select the device you want to access.
You will find all your device under the device tab .
Select the device from the list where you want to retrieve the files from.
As you can seen there are more options after you expanded the device.
For retrieving files we select the `Applications` option.
This wil give us a list of the installed applications:
You fill see the full file list that is in the application sandbox. Now just select the file you need and hit Download.
[[UIDevice currentDevice] uniqueIdentifier]
got deprecated.Well I don’t agree with them, this is about the smartest thing they did. If only for the privacy of the user.
Let me explain my self, I’ve bought a second-hand iPhone 3GS to replace my old 3G.
The previous owner wiped the device clean, like you should when you sell it.
But as soon as I started to install some apps, it was clear that the device was linked to the user. A game pre-filled the user name, which was the username used by the previous owner. Definitely the sort of thing you want.
Well I’ve yet to find an app that gave me more personal information about the the previous owner. But what if the Facebook would let me login because it checks the UDID
.
It seems that there are many games that do this and it is just wrong.
]]>The magazine is in Dutch and you can buy it online.
]]>