Your SlideShare is downloading. ×
Beginning with basics of iOS
Beginning with basics of iOS
Beginning with basics of iOS
Beginning with basics of iOS
Beginning with basics of iOS
Beginning with basics of iOS
Beginning with basics of iOS
Beginning with basics of iOS
Beginning with basics of iOS
Beginning with basics of iOS
Beginning with basics of iOS
Beginning with basics of iOS
Beginning with basics of iOS
Beginning with basics of iOS
Beginning with basics of iOS
Beginning with basics of iOS
Beginning with basics of iOS
Beginning with basics of iOS
Beginning with basics of iOS
Beginning with basics of iOS
Beginning with basics of iOS
Beginning with basics of iOS
Beginning with basics of iOS
Beginning with basics of iOS
Beginning with basics of iOS
Beginning with basics of iOS
Beginning with basics of iOS
Beginning with basics of iOS
Beginning with basics of iOS
Beginning with basics of iOS
Beginning with basics of iOS
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Beginning with basics of iOS

2,714

Published on

The iOS – previously known as iPhone OS is an Operating System of Apple Inc. for all its mobile devices.

The iOS – previously known as iPhone OS is an Operating System of Apple Inc. for all its mobile devices.

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
2,714
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
72
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. No. 01/2011 December 2011 www.icodermag.comBeginning with basics of iOSTreading New WatersStoryboard and ARCTop Errors andRisks in iOSThe All New iOS 5Siri – Worth the Hype?Getting Your First App to MarketGets You Paid – It Doesn’t Have To Be Good
  • 2. december 2011 www.icodermag.com Greetings iCoders! Especially for You we started iCoder magazine. First issue is about iOS fundamentals and iOS 5 new features, but don’t think iCoder is only for beginners, everyone interested in Apple mobile operating system programming will find something interesting. Our magazine is made by programmers for programmers, so You will find here a lot of interesting and useful stuff like full articles about iOS programming, tutorials, reviews, app and accessories tests, information about new frameworks and plug-ins for xcode. We’re open for Your feedback and cooperation, so don’t hesitate and write to us if You have any suggestions about iCoder magazine or want to submit an article or any other useful feedback. It’s You who can make iCoder the best magazine about iOS programming in the world. Have a good reading and come back for more. Maciej Michałowski Editor in Chief maciej.michalowski@software.com.pl icoder magazine Production director: Published by: Ałła Zalewska FX Press Sp. z o.o. Sp.K. Postal Address: President: FX Press Sp. z o.o. Sp.K., Ałła Zalewska ul. Bokserska 1, 02-682 Warszawa, Poland alla.zalewska@software.com.pl tel. +48 600 649 676 www.icodermag.com editor in chief: Maciej Michałowski Advertising: maciej.michalowski@software.com.pl alla.zalewska@software.com.pl editors: All trade marks presented in the magazine were used Ewa Zasadzka only for informative purposes. All rights to trade marks Michał Pietruszkiewicz presented in the magazine are reserved by the companies Rafał Przybylski which own them. The FX Press Sp. z o.o. Sp.K. works individually from design and dTP: Apple. The iCoder Magazine team reserves the right Aneta Jones not to be responsible for the topicality, correctness, Eurodesign completeness or quality of the information provided www.euro-design.info by contributors.2 www.icodermag.com 01/2011
  • 3. conTenTs TuTORIAl beginning with basics of ios 5 Softweb Solutions Inc. Getting Your First App to market Gets You Paid – It doesn’t Have To be Good 8 Ian Marriot IOS API Treading new Waters, storyboard and Arc 13 Li Mengran WHAT’S NEW IN IOS The All new ios 5 22 Manish Nath SECuRITY Top errors and risks in ios – should be addressed by the developers 27 Krzysztof Wołk REvIEW siri – Worth the Hype 31 Alex Allegro3 www.icodermag.com 01/2011
  • 4. TuTorIAl beginning with basics of ios Softweb Solutions Inc. The author, Softweb Solutions is an ISO 9001:2008 Certified and Microsoft Gold Certified, Chicago- based IT service Provider Company that offers industry specified solutions through its knowledge and expertise. Combining unparalleled experience with the state of the art technical competencies, Softweb Solutions provides outstanding solutions to its global clients. The company offers end to end solutions for Custom Web Application Development, Mobile Application Development, eCommerce Development, Mobile SEO, Rich Internet Application development, Legacy Migration, et al. AbouT Ios The iOS – previously known as iPhone OS is an Operating System of Apple Inc. for all its mobile devices. The iOS is the heart of iPhone, iPad, and iPod Touch de- vices. For designing and developing iOS applications, devel- opers use Xcode and IDE [Apple’s integrated development environment]. Xcode is used to design the user interface of the application as it provides all necessary tools for writing the code for it. After developing the application for iOS, user can run it on iPhone, iPad, Mac, and iPod Touch devices. After the completion of designing and developing the iOS application, it is needed to be submitted to the App Store – the secure market place where iOS users get their applica- tions. Courtesy: developer.apple.com The Operating system - iOS manages the device hardware layers of ios: and provides the technologies that are required to implement native apps. The iOS SDK have all the tools and interfaces that are needed to develop, install, run, and test the native ap- plications. The native apps are physically installed on an Apple device and therefore they are always available to the Apple users, even in the Airplane mode. THe Ios ArcHITecTure The iOS architecture is similar to the basic architecture found in Mac OS X. At the highest level, iOS acts as an intermediary between the underlying hardware and the applications that appear on the screen, as shown in the VersIons HIsTorY oF Ios below figure. The applications we create rarely talk to the Being an early adopter of Mobile Technologies, it is easier underlying hardware directly. Instead, applications com- for Softweb Solutions to explain the whole history of iOS municate with the hardware through a set of well-defined versions. Let us have a look at the gradual development of system interfaces that protect the application from hard- iOS. ware changes. This abstraction makes it easy to write ap- On 29th June, 2007, Apple Inc. released the first version plications that work consistently on devices with different of iOS with the first iPhone. hardware capabilities. On 11th July, 2008, Apple publicly released iPhone OS5 www.icodermag.com 01/2011
  • 5. beGInnInG WITH bAsIcs oF Ios TuTorIAl 2.0, with later upgrades of version 2.2 available for all mo- buIldInG Ios APPlIcATIon dels. The major release of 2.0 became available with the Before developing a new iOS application, it is important to fa- release of iPhone 3G. miliarize yourself with the basic concepts, fundamental design On 17th June, 2009, iOS version 3.0 was released with patterns and techniques. Basically, iOS assumes that all the upgraded through version 3.1.3. 3.0 version became ava- applications are built using the Model-View-Controller design ilable with the iPhone 3GS. First generation Apple devices pattern. Here we, Softweb Solutions explains the steps to – iPhone and iPod Touch has iOS version 3.1.3. build the simplest application “Hello World”. Later iPad was released with iOS 3.2 version which was specifically designed for the iPad. steps for building “Hello World” application – Later on 21st June, 2010, iOS 4.0 was released available 1] Open Xcode and click File > New Project. Select View-based- only to iPhone 4.0 and iPod Touch. While the second ge- application and click “Choose” button. After choosing, name the neration iPod Touch and iPhone 3G devices have iOS 4.2.1 project as “Hello World” and save it. After saving the project, you as their latest version. The first version to get major equ- will have a template for your Hello World iPhone Project. ivalent features to the iPhone and iPad is iOS 4.2. Later the sequence of iOS 4.2 was continued for the CDMA iPhone 2] Click on “Build and Go” button to run this template appli- and 4.3 was released for other devices as an upgrade. cation which will start an iPhone stimulator. After that clicking On 6th June, 2011, Apple previewed iOS version 5, Ap- on the “Home” button will show you a “Hello World” icon ple TV 4.4 beta, and iOS SDK 5 beta along with iCloud on the iPhone stimulator dashboard. Clicking it again will open beta. This update also introduced iMessage chat feature wi- the application. That is why, iPhone stimulator is considered thin the devices running on iOS 5.0. With iMessage feature, as the best tool to test the application before deployment or users can send messages to other iPhones, iPad, and iPod before submitting the application to the Apple Store. Touch users, so that they don’t have to pay extra for text messages. Other additions made in iOS 5 are – new notification system, Newsstand subscription, integrated Twitter, re- minders application, enhancements to AirPlay, and over 200 other new features. Moreover, it supports all iPad mo- dels, iPhone 3GS, iPhone 4 GSM, iPhone 4 CDMA, iPod Touch – 3rd and 4th generation. This version release has taken iOS to the whole new 3] Now you need to open the Xcode Project and select level. The camera application of this version offers many “HelloWorldViewController.h” file and type the below new in-built useful features like in-built editing feature, lock code inside the interface – screen access to camera, volume up button use for clicking a photo, and others. IBOutlet UITextField *txtUserName; IBOutlet UILabel *lblUserTypedName; APPle – ITunes Also write this method before end of this class iTunes is how users play all their media on their Mac or PC and - (IBAction) submitYourName; add it to their Apple devices. iTunes is a computer program used for media playing, downloading, and organizing any digital music or 4] After you write the above code, your video files on the PC. It is also capable to manage contents on iPod, “HelloWorldViewController.h” file will look like below – iPhone, iPad, and iPod Touch. It’s very simple to use and understand. Search any required me- #import <UIKit/UIKit.h> dia file on iTunes that you are looking for, and sync it with your @interface HelloWorldViewController: Apple device to get it. Basically, iTunes has become the central hub UIViewController { of media world for all the Apple users. IBOutlet UITextField *txtUserName; Originally, iTunes was specifically released as a music store but la- IBOutlet UILabel *lblUserTypedName; ter in the subsequent versions of it, all other type of entertainment } were also supported that includes radio, films, apps, television - (IBAction) submitYourName; shows, and audio books. The purchase history can be also seen by @end clicking the “purchase history” button after opening iTunes.6 www.icodermag.com 01/2011
  • 6. beGInnInG WITH bAsIcs oF Ios TuTorIAl 5] The next step is to open “HelloWorldViewController.m” Final output of this “Hello World” Application file and type the following method before @end – (IBAction) submitYourName; { lblUserTypedName.text = txtUserName.text; } 6] Design on Interface builder – Open Xcode project and in it “Group and Files”. Looking at bottom you will find “NIB Files” in which you will find two design files for your classes when you expand it. One is MainWindow.xib – main window or entry point to the app and second one is HelloWorldViewController.xib file which is mapped to your controller class. Double click on the second class to open it inside the interface builder. 7] Click on Tools > Library and drag the text field into your View. After this, click on Tools > Inspector and write “Your Name” in the text field. dIFFerence beTWeen THe code For An 8] After typing your name, drag the text field from Library IPHone APPlIcATIon And IPAd APPlIcATIon to your view and also drag another Label inside View. Click on tools then and select “Size Inspector” and also change For iPad the width of the text field to 250. Also change the layout if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceI- center. diomPad) { 9] Last thing to do is to drag a button to the view (19) and WhatIsViewController *VC1 = [[WhatIsViewController alloc] then open Inspector again by selecting Tools > Inspector. initWithNibName:@”What_ipad” bundle:nil]; In the Title, type “Submit”. [self.navigationController pushViewController:VC1 animated:YES]; 10] Map the controller class variable function and methods [VC1 release]; with interface builder. From Interface builder, select “File’s } Owner” and from Tools, select “Connection Inspector”. For iPhone 11] After selecting them, you will see that two new vari- { ables are added in Connection Inspector – txtUserName WhatIsViewController *VC1 = [[WhatIsViewController alloc] and lblUserTypedName. You need to click on txtUser- initWithNibName:@” What_iphone” bundle:nil]; Name radio button and drag it to text field in View. Next [self.navigationController pushViewController:VC1 you need to do same with lblUserTypedName, that is, se- animated:YES]; lect radio button and drag it below label. [VC1 release]; } 12] Last thing you need to do is click on the “submitYour- Name” radio button and drag it to the button and then select touch down from the list. Although we may not be sure what will be next in iOS, be with us to keep in touch with the industry develop- 13] Finally close the interface and open Xcode. Then sim- ments. The authors of this article have taken utmost care ply press “Build and Go” button to run this “Hello World” in disseminating the information here but assume no re- Application. It will open the stimulator in iPhone. sponsibility for any kind of errors.7 www.icodermag.com 01/2011
  • 7. TuTorIAl Getting Your First App to market Gets You Paid – It doesn’t Have to be Good Ian Marriott Two years ago, I knew as much about making an app as loves a superhero. And everybody seems to love phys- I currently do about the political situation in Sweden, ics based action puzzle games at the moment. I must that is to say, very very little. It’s not that I wasn’t in- be on to a winner. Not only that, but what I’ve got so terested, I had always been an avid gamer, and dreamed far is cool to play. And what’s more, your abilities came up ways in which the current crop of games could be with choices. Protect or Destroy? Hero or Villain? What better, and how I’d do it right if I ever made a game by could possibly go wrong? myself. Then, I was reading a magazine, and came across an article about a game engine that was free, yet power- Turns out I wasn’t as clever as I thought I was (this has ful enough that some pretty big name studios were using been a running theme throughout my adult life). I’d nev- it. I decided to give it a go. That engine was Unity, and er even seen XCode before, and it was a labyrinth that it’s ridiculously flexible, easy to use and, in my opinion, would make David Bowie stop in his tracks and think, the best way to start creating apps for beginners on the “Me and my floating glass balls better leave that place market. (See: “Coding Isn’t What it Used to Be…”). well alone.” Figuring that out took a good couple of days. Thankfully, Unity does a fantastic job of creating One year ago, I lost my job. My partner was pregnant the project files for you, all you have to do is figure with our second child. To say I was motivated to do out the provisioning system. Oh, yes, the provisioning something… anything… to put food on the table would system… (See “Provisionally Provision for Provisioning be an underestimation of the heat that the burning caul- Provisions”) dron of poverty, on fire centimetres beneath me, had created. But what to do? The economic climate didn’t fill Then, despite the fact that I’d gone into iOS develop- me with confidence, but app development did. It seemed ment, I didn’t actually have an iPhone. Or an iPod Touch. like a great passive income stream, the market was (and Or an iPad. Or a Mac (contentious I know, but a virtual still is) expanding extremely quickly and it felt like if machine image on my Windows laptop had to suffice I was ever going to get on board that particular train, I’d for the first 3 apps). I knew the specifications of each better do it before another big company wanted me to device, but didn’t actually have one on which to test. do some extremely tedious things for very little money This was a mistake on so many levels. It was like trying again… I’d spent a bit of time with the engine at this to build a house without foundations. On a lake. Using point, and with what little money I had, stumped up for air. Installing my app on a device was next to impossible, the iOS license for it, alongside joining the iOS devel- I had to visit my brother after he’d returned from work oper program. I decided I was going to make a run at it. just to spend 20 minutes testing to find as many bugs as possible. Then the next day I’d try to fix those bugs, I’d been working on an idea for a couple of months be- but not be able to check for another 2 days whether it fore that, which seemed to be taking shape quite nicely, had worked. Everything I did was a guess. An educated and thought it would be a perfect fit for the iPhone guess, but a guess nonetheless. I’d already spent in ex- market. I was developing a superhero physics action puz- cess of five hundred dollars though, and in the situation zler. The basic premise was good, in my eyes. Everybody I was in, I couldn’t afford to buy a device of my own.8 www.icodermag.com 01/2011
  • 8. GeTTInG Your FIrsT APP... TuTorIAl Working this way forced me, quickly, to optimise my but I was straight on Facebook telling people to get on code. Everything became ‘hacky’. What started as iTunes. The game was on “New & Noteworthy” lists a smooth 80fps on the computer screen quickly got around the world and got thousands of downloads in its bogged down to one tenth of that on the device. Each first day of sale. My ad revenue came in thick and fast, level had about two hundred rigidbodies in, each collid- and I was seeing an ECPM (earnings per thousand im- ing with at least 2 others.The A4 processor just could pressions) around the hundred dollar mark. This was ex- not cope with what I was throwing at it. I tried to help tremely surprising as all the research I’d done suggested as best I could, cutting down the texture quality, not ten dollars was average. I started to think there might rendering the (originally beautiful) 3D skyline I’d cre- be hope, and that this game was actually good, just not ated. Removing any shader that took up any processing as good as I’d intended so I was disappointed, but good time of statistical significance. Everything that I could enough for the people downloading it. cut out I did. A bastardised version of my original pro- ject emerged, shaking, stuttering to life, and barely func- Once more, I was mistaken. The reviews the game re- tional. It was a horrific mess, and was about as fun to ceived were mediocre, at best. They were accurate and play as “Where’s the Soap” in a prison shower. As each fair, and generally, through what little playing I’d done feature got stripped down, what remained felt like less of my own game, I agreed with them. When I finally got than the sum of its parts. The only thing that worked the chance to play it though, a few things dawned on was the menu system. Without being able to test, me – Firstly, most people download a game from the I’d had to create a User Interface (UI) that worked on description and screenshots that you put into iTunes all screen sizes, dynamically changing to suit the orienta- Connect. They don’t look at reviews, and they rarely tion or resolution of the screen (not that the resolution read past the first four lines of your blurb. No matter ever changed on an iOS device, but you do have to cater how poor an app is, if it looks good, a lot of people for different devices), and this is probably the most use- will download it, which means you’ll get some money ful skill I learned from the entire project. back through the adverts. Second, nobody cares about a good menu system provided it works. They care about At this point, you already know that your product is a playable game. Mine wasn’t playable. This would have simply not up to scratch. You can polish and polish, but to be corrected for the future… and third, but probably it’ll just end up being a shiny turd, so I decided it was quite important, is to make sure that if you have an ad going to have to do. I couldn’t start over, I had to get supported game, make sure the adverts don’t show up a product out there, I needed the money more than upside down, cover half of your level select screen, and I needed artistic credibility, so I wrote the blurb, took randomly appear and disappear. It makes people acci- some screenshots, optimised the keywords and then… dently click on your ads, which generates quite a bit of I had no idea how I was going to make money from it. revenue, but is against the Terms of Service agreement Could I justify charging for a product that was substand- you hold with Apple and makes you look like a scumbag. ard? Of course, for me, the answer to that was a big I swear, in all the tests I’d done, this wasn’t happening… fat “No”. It had to be free. So, the only option was to integrate adverts in the product. This was done quick- Eventually, I had to remove the abomination from the ly (thanks to Prime31 – See: “Making Life Easier”) and app store completely. It wasn’t just bad, it was broken. then it was a case of figuring out Application Loader, and No amount of updating would have fixed it. Now that sending the package for review (See: “Final Hurdles”). I know what I’m doing a little better, I might return to I didn’t know what to expect at all. Judging by what peo- the idea, but it would be a ground up build. The game ple say about the review process, I was in severe doubt had to be put out of it’s misery. But not before I’d gar- as to whether or not my game would be accepted. And nered some information about sales trends on the app from the research I’d done, it was unlikely that I was store (See: “We Consume All That Is New!”). going to make the money back that I’d already spent, let alone an income to live on… Even through all this however, my initial foray into the world of app development was successful. Despite (or per- Fortunately, after two agonising weeks, the game fi- haps because of ) my naivety, it earned me enough money nally got approved. I couldn’t even download it myself, to buy a small range of test devices for my future projects,9 www.icodermag.com 01/2011
  • 9. GeTTInG Your FIrsT APP... TuTorIAl and fund the development of the next one. It was four but it’s important to set up before you do any testing on further apps down the line that my releases were good an actual device. There are two types of profile that you enough to produce the same kind of figures I’d accidently require, a development profile, for which you need to use stumbled into with my first, and I still have to be prolific specific devices, and a distribution profile for, erm, distri- with my releases to earn a wage. I’ll have had eleven apps bution. released in the first year of being a developer, with at least the same again planned for next year. My baseline To set up a development profile, first you must set up income for these projects, not including the initial sales at least one device on which to test. You need to get spike, works out about a dollar a day, per app. The initial the UDID number of the device, which can be found in sales spike on average buys an iPad. It’s unlikely to make iTunes, or for ease, search “UDID” on the app store and you rich, but as a passive income generator it helps. download one of the free apps from there Go to the iOS development portal and click the “Provisioning Portal” Becoming an app developer has, without a doubt, changed option at the top right, then click “Add Devices” and fill my life for the better. I’d recommend it to anybody with in the form you’re presented with. the drive and determination to keep at it, and make it work for them. Your first forays into the app world prob- Once the device is set up, you need to set up a new “App ably won’t set the world ablaze, and will likely be full of ID”, so in the provisioning portal, click “App ID”, and mistakes, bugs (sorry, features) and plain bad design, but “New App ID”, then fill in the details as shown below: that isn’t what’s important. What matters is getting your app out there in the market, showing you that it can gen- erate some income, regardless of its quality. Put your work out there for the world to see and be proud to say that not only are you learning, but you are doing. And you are getting paid to do it. codInG Isn’T WHAT IT used To be… Unity (http://www.unity3d.com) is the most flexible game engine I’ve ever had the pleasure of using. In terms of 2D games, there are probably better solutions, but with the third party add-ons available through the Unity As- set Store, they won’t be that much better. In terms of 3D engines, it’s not Unreal, but take a look at games like Shadowgun and you’ll see what it’s capable of graphically. From a code based standpoint, you can use C# or Uni- The next step is to create the development provisioning tyScript (a version of JavaScript, so if you’re familiar with profile itself. Click the “Provisioning” tab on the left hand web development you’ll have no trouble picking it up). side, now, in the main box, create a new development You don’t have to worry as much about coding with Unity profile by clicking “New Profile”. A form like this should as you would in practically any other engine, although appear: it’s worth noting that you WILL need to get your head around the basics at least, especially as an Indy where you have to be a Jack of all trades. There are loads of tutorials to help you through this, and a pretty helpful community if you’re not trying to leap in and make the next World of Warcraft without knowing the difference between a rigidbody and a collider. ProVIsIonAllY ProVIsIon Make sure the fields are filled in, your App ID is selected, For ProVIsIonInG ProVIsIons and your testing devices are selected. Your app will only When making an app, provisioning can be an afterthought, work on devices that you have chosen to develop for, and10 www.icodermag.com 01/2011
  • 10. GeTTInG Your FIrsT APP... TuTorIAl have the UDID’s registered. Submit the form. Now, it may FInAl Hurdles say that your profile is “Pending”. Refresh the page and So, you’ve completed your app and it’s ready to be sent to you will be able to download it. Once downloaded, sim- Apple, but there are a few final hurdles and hoops to jump ply open the file in XCode and it will be ready for use. through. One issue that many people come across is non- Repeat these steps, without the specific devices, under public API use. Don’t do it, they’ll find it and reject your Provisioning>Distribution for your distribution certificate. binary, which means more work for you later and scuppers The final step is to then attach this profile to your app in your release plans. To upload your binary to Apple’s serv- XCode. In the app settings, scroll down to “Code Signing”, ers you’ll need to use Application Loader. Set up the binary and make sure that the signing identity is set as the profile as “Ready for Upload” in iTunes Connect, the run Appli- you just created: cation Loader, select the option to upload your package, choose your app ID from the drop down list and upload your binary (If you haven’t built for archiving in XCode, you’ll need to zip your .app file and send that, otherwise just use the zip file of your app) and hope that you don’t get any failure notices. Any of these that come up are eas- ily fixed in general, just Google the specific issue you get. Your info.plist file might get you into trouble here, make sure that the UIRequiredCapabilities array is correctly set up and that the build settings match (ie, armv6 or armv7 – And that’s it! You should now be able to build your app and I only ever build for armv7 devices now as pre-3gs install it on a device. Testing in the XCode environment iPhones and Generation 2 or lower iPod touches are such works quite well, but if you are using Unity, this will not a small share of the market, and don’t support iAd). be an option. Some people use the Unity Remote, I prefer to install on the device and see how it actually runs. I’ve Once your binary is “Waiting for Review”, you simply learned my lessons the hard way on that one. have to wait. The Apple staff get through the submissions pretty quickly, considering the number they receive. For mAkInG lIFe eAsIer a new app, it takes about ten working days to be approved, Anybody that has had anything to do with Unity will sometimes longer, but not often. For an update, about five know about the plug-ins that can be used, and anybody in working days is average. Then, you’re good to go. Or not. iOS development with Unity will have heard of Prime31 Rejections don’t come about too often if you keep to the (http://www.prime31.com). The plug-ins that this company submission guidelines, but occasionally you’ll have made an have developed are staggeringly useful, priced extremely error that’s slipped through testing, or you’ll be pushing fairly, get customer support in a way that we should all a boundary, or (please god no) you’ll have submitted a fart aspire to and are installed in a huge number of iOS apps, soundboard. When you are rejected, generally you get including every single one of mine. It makes calling native a specific reason for it, which you can then go about in functions on iOS easy (and offered for free), improves on a couple of ways. The first way, you can complain, moan, the inbuilt Unity GUI system (also free), integrates with berate and cry about it, get people’s backs up and make life Facebook and Twitter with about 2 lines of code, uses Ap- harder for you in future. The second is that you can fix the ple’s GameCenter for scores, achievements, turn based problems, whatever they may be, and resubmit your app. and real time multiplayer, integrates adverts through a ton The second way usually works better… of different portals and uses StoreKit for in-app purchas- es. There are multiple other plug-ins that are offered too We consume All THAT Is neW! which increase functionality still further, making what can Apps available on the App Store have an extremely ‘long be a quite complicated and somewhat annoying process tail’. They continue to move a few units every day for a complete breeze. If there’s one company that has allowed months, maybe even years, after release. However, most of me to build a portfolio of apps quickly, it’s Prime31. your downloads (unless you get featured by Apple them- selves, get yourself reviewed or featured on a big site like Toucharcade or TechCrunch, or you invest in a program like FAAD) will come in the first few days of release. This is the graph for downloads of my first release, although11 www.icodermag.com 01/2011
  • 11. GeTTInG Your FIrsT APP... TuTorIAl due to restrictions in the developer license, specific numbers have had to be removed: As you can see from these daily figures, the first day is the most crucial. I now release my apps on a Friday or Saturday to maximise these effects, as these are also the days where apps gain most impressions from the ad networks, as you can see from this graph of last weeks’ iAd requests (again, numbers removed as we’re prohibited from sharing specifics): About the author: Ian marriott Ian makes apps under the name EyeSix Games (http://www.eyesixgames.co.uk), his latest release is Calm 2 It makes sense here that in order to maximise profitability you (http://itunes.apple.com/us/app/ have to up that original spike as much as possible. Not only calm-2/id484539101?ls=1&mt=8) does this mean more initial downloads, but as there are less and can be followed @EyeSix releases at a weekend it means you get a higher chart placing, on Twitter. Sometimes he puts which in turn means you’re higher on the search results and pictures at a slight angle just gives the user a greater chance of finding your app. to annoy people.12 www.icodermag.com 01/2011
  • 12. ios API Treading new Waters, storyboard and Arc Li Mengran iOS 5 and Xcode 4 have recently been released, with many exciting new features such as storyboards, Automatic Reference Counting (ARC), GLKit, Core Image, iCloud and Twitter integration. For a complete reference, it’s better to read Apple’s release notes. However, that can be overwhelming and intimidating for a starting point, if one wants to quickly try out the shiny new toys. Therefore, like many others, I love reading hands-on tutorials and writing some test pro jects before reading the release notes. Having enjoyed a lot of good tutorials from the developer community in the past, I think I should pay back the community by contributing a simple tutorial. 1. InTroducTIon tions Use Storyboard and Use Automatic Reference This tutorial familiarizes you with two new features of IOS 5, Counting, as shown in Fig. 1; the first one for obvious storyboard and ARC, by going through example projects step reasons, the second one for ease of coding. by step. Along the way, we’ll also introduce some new handy shortcuts brought by Xcode 4. 2. sTorYboArd Storyboard is a much improved interface builder and a lot more. It eliminates for us a lot of hassles in interface design, especially transitions between different views. There are new two concepts introduced with story- board, scene and segue. A scene is a UIViewController Figure 1: New Project that manages all the contents in one screen, and a segue is a transition between two scenes. After we finish with the project creation wizard, take a look Usually an app only requires one storyboard, in which we at the Project Navigator on the left of the screen, as can draw all the scenes for our app and link them by segues, shown in Fig. 2. It should be opened by default. If not, you in a simple and intuitive manner. Finally we have a tool that lets can open the project navigator by going from the top menu us manage all the visual aspects of our programs seamlessly View g Navigators g Show Project Navigator. in one place. Unfortunately these shiny new features are only Notice the highlighted storyboard file there. Instead of the available on iOS 5. .nib file, we work with this file to draw our interfaces. Now In this section we’ll give a simple tutorial on storyboard click on this file to open it in the interface builder. and show some of the new shortcuts in interface building brought by Xcode 4. 2.1 first example In our first example, we are going to create an iPhone app with two views that can pass data strings to each other. Let’s begin by going from the top menu File g New g New Project, then select Single View Application. Select iPhone in the Device Family, and name our project as ”StoryBoardDemo”, and make sure to check the two op- Figure 2: Project Navigator13 www.icodermag.com 01/2011
  • 13. TreAdInG neW WATers, ios API sTorYboArd And Arc You should see a blank view created by the wizard, as shown • Hold the control key and drag the Text Field to in Fig. 3. This controller class for this view is ViewCon- ViewController.h, in between the start and end of troller, implemented in the files ViewController.h and the interface definition, as shown in Fig. 4. ViewController.m, which are created by the wizard. We • A small window should pop up as shown in Fig. 5. Let’s call ViewController a scene in our storyboard. We can set the name to be ”textField” and make sure you zoom in or out by right clicking on a blank area and selecting change the storage option to strong. We won’t the appropriate option. explain why we need to set it this way in this section, Notice the arrow from nowhere pointing at this scene. but one simple rule of thumb is that if you would It indicates the fact that this is the initial scene, the scene declare this IBOutlet as retain before IOS 4, that immediately shows up when we start our application. It is you need to set its storage option to strong. very important to set the initial scene. In this example, the • Click Connect. wizard automatically sets it for us. However, if you are starting • Do the same for the Label and name it ”outputLabel”. from other templates, you may need to set it manually. You can do that in three steps: • Click on a scene to select it. • Open the attributes inspector by going from top menu View g Utilities g Show Attributes Inspector. • Check the option Is Initial View Controller. Figure 4: Assistant Editor1 Figure 3: Initial Scene Drag from the object library to the initial scene a Text Field, a Round Rect Button and a Label. Double click on the button and change its text to ”Switch To New View”. We’ll be using the Text Field to collect some user input, and the Label to display some string passed by the other Figure 5: Assistant Editor2 view which we are going to create in a short while. Therefore we need to hook up the Text Field and La- This should add the following two proper- bel to some IBOutlet in ViewController. we now show ties in ViewController.h and synthesize them in how to do it with a cool new shortcut brought by Xcode 4. ViewController.m, in addition to hooking them up to the right parts. • Go from top menu View g Assistant Editor g Show Assistant Editor to open the assistant editor. @property (strong, nonatomic) IBOutlet By default, you should see the editor and assistant UITextField *textField; editor opened side by side, and ViewController.h @property (strong, nonatomic) IBOutlet is automatically opened in the assistant editor window. UILabel *outputLabel;14 www.icodermag.com 01/2011
  • 14. TreAdInG neW WATers, ios API sTorYboArd And Arc That’s pretty neat, isn’t it. Now close the assistant editor File, then select UIViewController subclass, and then by clicking on the cross button in the top right corner of give it the name NewVewController. When you are pre- its window. sented with the options, remember to uncheck Targeted Right now the onscreen keyboard doesn’t retract when for iPad and With XIB for user interface. we finish entering in the Text Field. We have to write an IBAction handler to do that. Open the storyboard in the editor by clicking it in the Add the following definition in ViewController.h: Project Navigator. Click on the new View Controller to select it. Open the Identity Inspector by going from - (IBAction)textFieldReturn:(id)sender; top menu View g Utilities g Show Identity In- Add the following method body in ViewController.m: spector. In the Custom Class tab in Identity Inspec- - (IBAction)textFieldReturn:(id)sender tor, open the class drop down menu as shown in Figure. 7, { and select NewViewController. [sender resignFirstResponder]; } Basically this handler asks the first responder, in this case the onscreen keyboard to retract. Open the storyboard and click on the Text Field to select it. Open the Connections Inspector by going from top menu View g Utilities g Show Connections Inspector. In the Sent Events tab, while holding the con- trol key, drag from the circle to the right of Did End On Exit to the View Controller button at the bottom as shown in Fig. 6. A small black window should popup with only one option textFieldReturn. Select it should work as we want now. Figure 7: New View Controller Identity Draw a Text Field, Round Rect Button and Label on the new View Controller in a similar fashion as our original View Controller. Change the text on the button to ”Switch To Old View”. Also remember to make the onscreen keyboard for the new Text Field retract in a similar manner. Hook the Text Field to the property textField and Label to the property outputLabel in NewViewCon- troller in a similar fashion as the original view. Now is the time to create the segue! While holding the control key, drag the button in the original View Control- ler to the new View Controller, as shown in Fig. 8. Figure 6: Text Field Return Drag a View Controller from the object library to the storyboard. We need to create a new class for this new View Controller. Right click on the StoryBoardDemo group and select New Figure 8: Create Segue 115 www.icodermag.com 01/2011
  • 15. TreAdInG neW WATers, ios API sTorYboArd And Arc A small black window with three options should pop up, needed to create another segue from the new View Con- as shown in Fig. 9. Select modal from the options. The troller to the old View Controller. This doesn’t work, modal style segue is such that the new screen completely because every time a segue is invoked to transition from blocks the underlying screen, with which the user cannot a source View Controller to a destination View Con- interact until the screen on top is closed. The push style troller, it actually creates a new instance of the destina- segue is only for view controllers embedded in UINaviga- tion View Controller. Instead of going back to the source tionControllers or UITabBarControllers. If we use it here, scene, the segue I envisaged would just go to a new instance it doesn’t work. of the source scene. There is no ”reverse” segue per se. In order to go back, we need to close the new scene. Add the following IBAction handler definition in NewViewController.h. - (IBAction)buttonPress:(id)sender; Figure 9: Create Segue 2 Add the following IBAction handler implementation in You should see something like this in your storyboard, NewViewController.m. as shown in Fig. 10. - (IBAction)buttonPress:(id)sender{ [self dismissViewControllerAnimated:YES completion:nil]; } The dismissViewControllerAnimated:completion: method is new in iOS 5. It is different from the old method dismissModalViewControllerAnimated: in that it has an additional parameter, which is a block, that gives us the ability to execute additional code after the dismissal of the screen. The old method still works in IOS 5. Open the storyboard. Click on the button in the new Figure 10: Segue Created View Controller to select it, then while holding control key, drag it to the New View Controller button at the Notice the arrow with knot connecting the original View bottom, as shown in Fig. 11. Controller and the new View Controller. That repre- sents the segue. Select the segue by clicking on the knot. Open the Attributes Inspector. Set the identifier of the segue to ”OldToNew”. Note that we can also change the transition animation for this segue in the Attributes Inspec- tor. There are four types of transitions provided by UIKit, which we can subclass to customize. They are Cover Ver- tical, Flip Horizontal, Cross Dissolve and Par- tial Curve. By default, the transition for modal style seg- ue is Cover Vertical, which slides the destination scene vertically upwards to cover the source scene. Now we can already compile and see the transition to the new View Controller. Notice the convenience that this is done without having to write an IBAction handler for the button touch down event. However, there is no way to go back to the original screen yet. The first time I’ve tried Storyboard, I though I just Figure 11: Button Press 116 www.icodermag.com 01/2011
  • 16. TreAdInG neW WATers, ios API sTorYboArd And Arc Select buttonPress from the small black window that prepareForSegue:sender: to the following: pops up. Compile and run it; now pressing the button in the new scene should bring us back to the original. - (void)prepareForSegue:(UIStoryboardSegue *) segue sender:(id)sender{ Next we want to pass the string entered in the Text Field if([[segue identifier] isEqualToString: in the original View Controller to the new one and dis- @”OldToNew”]){ play it in the new one’s Label. We do this by importing NewViewController *nvc = (NewViewController *) NewViewController.h in ViewController.h, and imple- segue.destinationViewController; menting the method prepareForSegue:sender:, which nvc.msg = self.textField.text; is called by the system when the transition happens. } One initial try of the implementation is as follows: } - (void)prepareForSegue:(UIStoryboardSegue *) Uncomment the method viewDidLoad in segue sender:(id)sender{ NewViewController.m and change it to: if([[segue identifier] isEqualToString:@”OldToNew”]){ - (void)viewDidLoad NewViewController *nvc = (NewViewController *) { segue.destinationViewController; [super viewDidLoad]; nvc.outputLabel.text = self.textField.text; self.outputLabel.text = self.msg; } } } Now the string in the Text Field from the original view The idea here is to first check if it is the segue we want can be successfully displayed in the destination view. You to deal with by matching its identifier, then get a reference can try it to convince yourself. To pass back data from the to the destination View Controller, and set the text of destination View Controller to the original View Con- its outputLabel to the text in the Text Field of the troller, we need to add a protocol and delegate. original View Controller. However, this will not work, not because the text prop- Add in the definition for protocol NewViewControllerDel erty of the outputLabel is not set. The reason is that and the property delegate in NewViewController.h, so the method prepareForSegue:sender: is called after that NewViewController.h becomes the following: the creation of the instance of New View Controller, but before the loading of its view. As a result, when the #import <UIKit/UIKit.h> view of New View Controller loads, it overwrites the text property of outputLabel by the value we set in the story- @class NewViewController; board. One way to overcome this is to add to New View Con- @protocol NewViewControllerDel <NSObject> troller a new property that is not changed in the view - (void)newViewControllerClose: loading process, pass the value to that property and then (NewViewController*)controller; update the view in the viewDidLoad method of New View @end Controller. @interface NewViewController : UIViewController Add the following property definition in @property (strong, nonatomic) IBOutlet UIText- NewViewController.h: Field *textField; @property (strong, nonatomic) IBOutlet UILabel @property (strong, nonatomic) NSString *msg; *outputLabel; @property (strong, nonatomic) NSString *msg; Synthesize it as follows in NewViewController.m: @property (weak, nonatomic) id <NewViewCon- trollerDel> delegate; @synthesize msg; - (IBAction)buttonPress:(id)sender; - (IBAction)textFieldReturn:(id)sender; Change the implementation for the method @end17 www.icodermag.com 01/2011
  • 17. TreAdInG neW WATers, ios API sTorYboArd And Arc Note that it is customary to pass the reference of the ob- to tell the destination View Controller that the source ject calling the delegate function as the first parameter so View Controller is its delegate, like follows: that the delegate always knows who calls it. Usually this one parameter is enough, since we could pass messages to - (void)prepareForSegue:(UIStoryboardSegue *) the delegating object to retrieve whatever information segue sender:(id)sender{ we want. if([[segue identifier] Synthesize the property delegate in NewViewController.m isEqualToString:@”OldToNew”]){ as follows: NewViewController *nvc = (NewViewController *) segue.destinationViewController; @synthesize delegate; nvc.msg = self.textField.text; nvc.delegate = self; Note that the storage qualifier for property ”delegate” } is set to weak so as to avoid retain cycles, which we will } talk about later. Add in a line in the buttonPress method of NewView- Now the code should work as we want. Compile and run Controller to call the delegate method, like the following: it. Fig. 12 shows five screens. - (IBAction)buttonPress:(id)sender{ From top to bottom, left to right, the first screen is what [self.delegate newViewControllerClose:self]; we should see when we start the app; the second is after [self dismissViewControllerAnimated:YES we have entered the message ”hello world” in the Text completion:nil]; Field; the third one is after we click on the button and } transition to the new scene, where the message we’ve passed from the original scene is displayed below the but- Declare that ViewController now implements the ton; the fourth one is after we’ve entered the message protocol NewViewControllerDel in ViewController.h ”hello back” in the Text Field in the new scene; the last so that it is now the following: one is after we close the new scene, go back to the original scene and display the message passed from the new scene #import <UIKit/UIKit.h> below the button. #import “NewViewController.h” 2.2 Important Points To Take note @interface ViewController : UIViewController • Always remember to set an initial scene. It’s <NewViewControllerDel>; automatically set to be the default View Controller @property (strong, nonatomic) IBOutlet UIText- when you start with a single view project template. Field *textField; Should you start from some other template, e.g. the @property (strong, nonatomic) IBOutlet UILabel empty project template, you need to do it manually. *outputLabel; - (IBAction)textFieldReturn:(id)sender; • Segue always creates a new instance of the destination @end View Controller. Consequently it is not possible to create a ”reverse” segue, i.e. a segue that transitions Implement the protocol method NewViewController- back to the source View Controller. You have to do Close in ViewController.m like follows: it through delegate. - (void)newViewControllerClose: • Implement the prepareForSegue:sender: method (NewViewController*)controller; to pass data to the destination View Controller. { This method is called after the instance of the self.outputLabel.text = controller.textField. destination View Controller is created, but before its text; view is loaded. } • The push style segue is only used for scenes embedded Add in a line in the method prepareForSegue:sender: in UINavigationControllers or UITabBarControllers.18 www.icodermag.com 01/2011
  • 18. TreAdInG neW WATers, ios API sTorYboArd And Arc • We need to give each segue an identifier in order to this part into two subsections; the first one on how ARC differentiate between them. This identifier must be works, second one on interoperability with legacy code. unique in the scope of the source View Controller. That means different scenes may have segues sharing the 3.1 How Arc works same identifier. You need to enable ARC for it to work. You can do that when you start a new project, where the wizard presents 3. Arc, more subTle THAn IT seems you the option of enabling ARC, as shown in the previous The traditional IOS memory management model is all section. Checking that option enables ARC for the entire about the reference count, i.e. the number of references project. to an object from the other active objects in a lifecycle. The creator of the object has a reference to it; the other Basically ARC works by adding code at compile time to objects can increase the number of references to it if they ensure that objects live only as long as necessary, by adding call its retain method. The other objects can decrease retain, release and autorelease at appropriate plac- the reference count of the object in question by calling its es automatically. For example, below is code snippet for release method, to a non-negative number. They do it af- a typical object creation. ter they are done with the object. An object with zero ref- erence count in the end of the lifecycle will be deallocated. NSObject *obj = [[NSObject alloc] init]; However, if the creator of the object returns the object by // some code block a method, retain and release alone will not get us the behavious we want. Calling release on it will destroy it If obj is no longer used after some code block, the com- before the caller of the method could get it as the return piler automatically adds the invocation of the release value. On the other hand, not calling release on it before method on obj after the code block. If the obj is returned, we exit the method scope will cause memory leak. In this the compiler automatically adds the invocation of the au- case we call the method autorelease on the object, put- torelease method on obj. If we get reference to an au- ting it into an autorelease pool, which when destroyed by toreleased object like luckyNumArr in the following code, the system, will decrement the object’s reference count and later need to use it, the compiler can detect it and add by one. Great care has to be taken in order not to leak the call to retain method. memory, or create dangling pointers. Automatic Reference Counting, as its name suggests, luckyNumArr = [NSArray arrayWithObjects:tempArr is a feature that automatically counts the reference to an count:luckyCount]; object in our code and add the retain and release calls to it appropriately so that we humans do not have to both- The automatic deduction power of the compiler is pretty er any more. That sounds very nice, isn’t it. When I first powerful, but not always reliable. In particular, it does not heard about Automatic Reference Counting (ARC), I felt guard against retain cycle, which happens when for instance that it was too good to be true. Reading the release notes object A retains object B and object B retains A, resulting in details confirms my suspicion. There is no free lunch in a cycle of reference, preventing both objects from being in this world. To be fair, ARC does simplify a lot of work, deallocated. and I believe they will make it much better in the future. We can provide hints to the compiler by preceding our However, there are a lot of subtleties we have to take into property and variable declarations with lifetime quali- consideration, in order to make the best out of ARC and fiers. avoid ugly mistakes. • For properties, we have the qualifiers strong and In this section we will not develop any example apps, weak. We assign the qualifier strong to objects we as code snippets suffice for demonstration. Before you want to own, just as we assign retain when ARC is start to try ARC, make sure you at least have XCode 4 on disabled. The qualifier weak is like the qualifier assign Snow Leopard, because although ARC is mostly a compile- when ARC is disabled, except that when this property time trick, it does require some runtime support. You can is deallocated, the property value is set to nil, instead only target IOS 4 and above for IOS, or Snow Leopard and of remaining as a dangling pointer.Note that zeroing above for OSX. Besides, you need Xcode 4 in Lion to de- weak references only work on IOS 5 and above for velop apps with ARC enabled for Snow Leopard. We divide IOS, Lion and above for OSX.19 www.icodermag.com 01/2011
  • 19. TreAdInG neW WATers, ios API sTorYboArd And Arc retain, assign and copy qualifiers cannot be used with – ( __bridge_transfer T) p does the cast and ARC. Remember that we assign the qualifier strong to decrement the CFRef by 1. the Iboutlets in the storyboard section? The pattern – ( __bridge_retained T) p does the cast and we should typically adopt for the Iboutlets is that increment the CFRef by 1. they are all set to weak, except for those from File’s Owner to top-level objects in a nib file or a storyboard • We cannot use NSAutoreleasePool objects. Instead scene, which are set to strong. we should embed the codes benefitting from the autorelease pool in an @autoreleasepool block • For variables, we have the following qualifiers: like this: – __strong is the default qualifier if we do not specify @autoreleasepool{ anything. It means that we intend to own the object //code benefitting from the pool in question. } – __weak specifies a zeroing weak reference to an object. According to Apple, this is more efficient than using – __unsafe_unretained specifies weak reference to NSAutoreleasePool. an object that leaves the pointer dangling after it has been deallocated. There are some pitfalls we need to avoid. – __autoreleasing is used for arguments passed by reference id* and autoreleased on return. • We need to be careful when using __weak variables on the stack, as they are immediately released when there Besides the new qualifiers, ARC also introduces new rules. is no strong reference to it. For instance, consider the We list the more relevant rules here: following code snippet: • In order not to mess up ARC’s deduction algorithm, we NSArray __weak *list=[NSArray arrayWithObject cannot explicitly invoke dealloc, retain, release, s:@”Tom”,@”Jerry”,nil]; retainCount or autorelease. Neither can we try to [self displayList:list]; surreptitiously invoke them through selectors like @selector(retain). Although list is used after the assignment, there is no strong reference to it. Therefore it is immediately deallo- We may implement a dealloc method to manage cated, and the method displayList: will display nothing resources. since list will be set to nil before invoking display- List:. • We cannot use the foundation functions NSAllocateObject or NSDeallocateObject. • We also have to ensure that an object passed by reference have the same lifetime qualifier as the • We cannot use object pointers in C structures. corresponding argument declaration. For example, • We cannot casually cast between id and void *. if we have the following code snippet: We need to use the following three bridging casts to inform ARC about the ownership of the object OperationInfo *info = nil; in question: __bridge, __bridge _transfer, and BOOL OK = [myObject __bridge _retained. The latter two should only be doOperationWithInfo:&info]; used when dealing with toll-free bridged Core if(!OK){ Foundation objects where we would normally have // blah blah blah to call cFretain and/or cFrelease to manage the // ... lifetime of Core Foundation objects. It works and info is implicitly declared to be strong. Now – ( __bridge T) p casts p to the type T with no if the method declaration of doOperationWithInfo: operation at all. No ownership is transferred. is the following:20 www.icodermag.com 01/2011
  • 20. TreAdInG neW WATers, ios API sTorYboArd And Arc -(BOOL)doOperationWithInfo:(OperationInfo * have a graph of objects, we would like to have within it __autoreleasing *)info; a spanning tree, i.e. a strict parent-child hierarchy, where we set the reference from parent to child as strong and Then there is a mismatch between the lifetime qualifier child to parent as weak. This usually does the trick. of info and the argument to the method doOperation- WithInfo:. In this case, the compiler rewrites the code 3.2 Interoperability into: ARC can work on a file by file basis, meaning we could have files with ARC disabled in an ARC enabled project. We OperationInfo __strong *info = nil; can enable ARC using the new -fobjc-arc compiler flag. OperationInfo __autoreleasing *tmp = info; In a project where ARC is enabled by default, we can dis- BOOL OK = [myObject able ARC for a specific file using the new -fno-objc-arc doOperationWithInfo:&tmp]; compiler flag. One more thing to take note when we want info = tmp; a mixture of ARC enabled and disabled files is that we can if(!OK){ not give a property a name that begins with new. // blah blah blah // ... 4 conclusIon I hope this simple tutorial can help you start having fun This would create an unnecessary temporary variable. with the shiny new toys! We can rectify this by changing the type of the argument to the method doOperationWithInfo: to id __strong About the author: * or declare the variable info as __autoreleasing. li mengran • We need to carefully manage the lifetime qualifiers in The author is currently a PHD student order to avoid having a strong reference cycle, which in the National University of Singapore. is the same thing as the old retain cycle. When we Figure 12: Result21 www.icodermag.com 01/2011
  • 21. WHAT’s neW In ios The All new ios 5 Manish Nath Icloud sTorAGe APIs The contents of the block are enclosed by curly braces, Using the iCloud storage APIs as shown in the following example: a user can view or edit those documents from any device with- @autoreleasepool out having to sync or transfer { files explicitly. Storing documents // Your code here in a user’s iCloud account also provides a layer of secu- } rity for that user. With the new iCloud storage loosing your device does not mean that you loose your data. A storyboard file captures your entire user interface in There are two ways that applications can take advantage one place and lets you define both the individual view of iCloud storage, each of which has a different intended controllers and the transitions between those view con- usage: trollers. Storyboards capture the flow of your overall user interface. • iCloud document storage – Use this feature to store If you are creating new applications, the Xcode templates user documents and data in the user’s iCloud account. come preconfigured to use storyboards. For other applica- tions, the process for using storyboards is as follows: • iCloud key-value data storage – Use this feature to share small amounts of data among instances of your 1. Configure your application’s Info.plist file to use application. storyboards: AuTomATIc reFerence counTInG • Add the UIMainStoryboardFile key and set its value to Automatic Reference Counting (ARC) is a feature built the name of your storyboard file. to simplify the process of managingthe lifetimes of Objective-C objects. ARC evaluates the lifetime require- • Remove the existing NSMainNibFile key. (Storyboards ments of your objects and automatically inserts the ap- replace the main nib file.) propriate method calls at compile time. 2. Create and configure the storyboard file in Xcode Some Restrictions with ARC : cusTomIze nATIVe uI elemenTs In Ios 5 • Do not call the retain, release, autorelease, or dealloc You can now customize the appearance of many UIKit methods in your code. views and controls to give your application a unique look and feel. For example, you might use these customiza- • Do not store object pointers in C structures. tions to make the standard system controls match the branding for the rest of your application. • Do not directly cast between object and nonobject types (for example, between id and void*). UIKit supports the following customizations: • No NSAutoreleasePool objects. • You can set the tint color, background image, and title position properties (among other) on a wide variety of Instead, you must use a new @autoreleasepool keyword objects, including toolbars, navigation bars, search bars, to mark the start of an autorelease block. buttons, sliders, and some other controls.22 www.icodermag.com 01/2011
  • 22. THe All neW ios 5 WHAT’s neW In ios • You can set attributes of some objects directly, or you forBarMetrics:UIBarMetricsLandscapePho- can set the default attributes to use for a class using an ne]; appearance proxy. // Customize the title text for *all* UINavigationBars An appearance proxy is an object you use to modify [[UINavigationBar appearance] setTitleTe- the default appearance of visual objects such as views xtAttributes: and bar items. Classes that adopt the UIAppearance [NSDictionary dictionaryWithObjectsAnd- protocol support the use of an appearance proxy. To Keys: modify the default appearance of such a class, retrieve [UIColor colorWithRed:255.0/255.0 its proxy object using the appearance class method and green:255.0/255.0 blue:255.0/255.0 alpha:1.0], call the returned object’s methods to set new default UITextAttributeTextColor, values. A proxy object implements those methods and [UIColor colorWithRed:0.0 green:0.0 properties from its proxied class that are tagged with blue:0.0 alpha:0.8], the UI_APPEARANCE_SELECTOR macro. For exam- UITextAttributeTextShadowColor, ple, you can use a proxy object to change the default [NSValue valueWithUIOffset:UIOffset- tint color (through the progressTintColor or trackTint- Make(0, -1)], Color properties) of the UIProgressView class. UITextAttributeTextShadowOffset, If you want to set a different default appearance based [UIFont fontWithName:@”Arial-Bold” on how a given object is used in your application,you can size:0.0], do so using the proxy object returned by the appearance- UITextAttributeFont, WhenContainedIn: method instead. For example, you use nil]]; this proxy object to set specific default values for a button only when it is contained inside a navigation bar. } Any changes you make with a proxy object are applied, at view layout time, to all instances of the class that exist or uIbarbuttonItem that are subsequently created. [[UIBarButtonItem appearance] setBackgroundIma- code snIPPeTs: ge:button24 forState:UIControlStateNormal barMetrics:UIBarMetricsLandscapePhone]; navigationbar [[UIBarButtonItem appearance] setTitleTextAt- - (void)customizeAppearance tributes: { [NSDictionary dictionaryWithObjectsAndKeys: // Create resizable images [UIColor colorWithRed:220.0/255.0 gre- UIImage *gradientImage44 = [[UIImage image- en:104.0/255.0 blue:1.0/255.0 alpha:1.0], Named:@”surf_gradient_textured_44”] UITextAttributeTextColor, resizableImageWithCapInsets:UIEdgeInset- [UIColor colorWithRed:1.0 green:1.0 sMake(0, 0, 0, 0)]; blue:1.0 alpha:1.0], UIImage *gradientImage32 = [[UIImage image- UITextAttributeTextShadowColor, Named:@”surf_gradient_textured_32”] [NSValue valueWithUIOffset:UIOffsetMake(0, resizableImageWithCapInsets:UIEdgeInset- 1)], sMake(0, 0, 0, 0)]; UITextAttributeTextShadowOffset, [UIFont fontWithName:@”AmericanTypewri- // Set the background image for *all* UINavigationBars ter” size:0.0], [[UINavigationBar appearance] setBackgroun- UITextAttributeFont, dImage:gradientImage44 nil] forBarMetrics:UIBarMetricsDefault]; forState:UIControlStateNormal]; [[UINavigationBar appearance] setBackgroun- dImage:gradientImage3223 www.icodermag.com 01/2011
  • 23. THe All neW ios 5 WHAT’s neW In ios uITabbar uIswitch [[UITabBar appearance] setBackgroundImage:tab- [rentSwitch setOnTintColor:[UIColor colorWi- Background]; thRed:0 green:175.0/255.0 blue:176.0/255.0 al- [[UITabBar appearance] setSelectionIndicatorI- pha:1.0]]; mage: [UIImage imageNamed:@”tab_select_indi- cator”]]; sTorYboArds uIslider [[UISlider appearance] setMaximumTrackImage- :maxImage forState:UIControlStateNormal]; [[UISlider appearance] setMinimumTrackImage:mi- nImage forState:UIControlStateNormal]; [[UISlider appearance] setThumbImage:thumbImage forState:UIControlStateNormal]; uIsegmentedcontrol If you have an app with many different screens then storyboards can help reduce the amount of glue code [[UISegmentedControl appearance] setBackgroun- you have to write to go from one screen to the next. dImage:segmentUnselected Instead of using a separate nib file for each view controller, forState:UIControlStateNormal barMetrics:U- your app uses a single storyboard that contains the de- IBarMetricsDefault]; signs of all of these view controllers and the relationships [[UISegmentedControl appearance] setBackgroun- between them. dImage:segmentSelected forState:UIControlStateSelected barMetric- Storyboards have a number of advantages over s:UIBarMetricsDefault]; regular nibs: [[UISegmentedControl appearance] setDividerIma- • With a storyboard you have a better conceptual ge:segmentUnselectedUnselected overview of all the screens in your app and the forLeftSegmentState:UIControlStateNormal connections between them. It’s easier to keep track rightSegmentState:UIControlStateNormal of everything because the entire design is in a single file, barMetrics:UIBarMetricsDefault]; rather than spread out over many separate nibs. [[UISegmentedControl appearance] setDividerIma- ge:segmentSelectedUnselected • The storyboard describes the transitions between the forLeftSegmentState:UIControlStateSelected various screens. These transitions are called “segues” rightSegmentState:UIControlStateNormal and you create them by simply ctrl-dragging from one barMetrics:UIBarMetricsDefault]; view controller to the next. Thanks to segues you need [[UISegmentedControl appearance] less code to take care of your UI. setDividerImage:segUnselectedSelected forLeftSegmentState:UIControlStateNormal • Storyboards make working with table views a lot easier rightSegmentState:UIControlStateSelected with the new prototype cells and static cells features. barMetrics:UIBarMetricsDefault]; You can design your table views almost completely in the storyboard editor, something else that cuts down on the amount of code you have to write.24 www.icodermag.com 01/2011
  • 24. THe All neW ios 5 WHAT’s neW In ios oPenGl es 2.0 WITH GlkIT Json In Ios 5 iOS 5 comes with a new set of APIs that makes de- iOS 5 has some new built-in APIs to make it really easy veloping with OpenGL much easier than it used to be. to read and write JSON. Over a period of time JSON has The new set of APIs is collectively known as GLKit. proven itself best for communication with a web service It contains four main sections: . For example, if you have an array of three strings, the JSON representation would simply be: • GlkView/GlkViewcontroller. These classes abstract out much of the boilerplate code it used [“test1”, “test2”, “test3”] to take to set up a basic OpenGL ES project. If you have a Pet object with member variables name, • Glkeffects. These classes implement common shading breed, and age, the JSON representation would simply behaviors used in OpenGL ES 1.0, to make transitioning be: to OpenGL ES 2.0 easier. They’re also a handy way to get some basic lighting and texturing working. {“name” : “Dusty”, “breed”: “Poodle”, “age”: 7} • Glmath. Prior to iOS 5, pretty much every game It’s that simple, which is why it’s so easy and popular to needed their own math library with common vector use. The reason JSON is important is that many third and matrix manipulation routines. parties such as Google, Yahoo, or Kiva make web ser- vices that return JSON formatted data when you visit • GlkTextureloader. This class makes it much easier a URL with a specified query string. If you write your to load images as textures to be used in OpenGL. own web service, you’ll also probably find it really easy Rather than having to write a complicated method to convert your data to JSON when sending to another dealing with tons of different image formats, loading party. If you’ve had to parse JSON in your iOS apps in a texture is now a single method call! the past, you’ve probably used a third party library such as JSON Framework. Arc In Ios 5 The most disruptive change in iOS 5 is the addition of Well with iOS 5, needing to use a third party library Automatic Reference Counting, or ARC for short. ARC for JSON parsing is a thing of the past. Apple has finally is a feature of the new LLVM 3.0 compiler and it com- added a JSON library in Cocoa and I must say I person- pletely does away with the manual memory management ally like it very much! that all iOS developers love to hate. You can turn objects like NSString, NSNumber, NSArray Using ARC in your own projects is extremely simple. and NSDictionary into JSON data and vice versa super You keep programming as usual, except that you no easily. And of course no need to include external librar- longer call retain, release and autorelease. That’s basi- ies – everything is done natively and super fast. cally all there is to it. core ImAGe In Ios 5  With Automatic Reference Counting enabled, the com- Core Image is a powerful framework that lets you easily piler will automatically insert retain, release and autore- apply filters to images, such as modifying the vibrance, lease in the correct places in your program. To migrate hue, or exposure. It uses the GPU (or CPU, user defin- your current app to ARC you can Edit > Refactor menu, able) to process the image data and is very fast. Fast you’ll see an option called migrate to objective- enough to do real time processing of video frames! c Arc. That tool will help convert your code to Arc. Core Image filters can stacked together to apply multiple ef- fects to an image or video frame at once. When multiple fil- The only problem that you might face would be ters are stacked together they are efficient because they cre- with 3rd party libraries used in your app which ate a modified single filter that is applied to the image, instead might not support Arc. of processing the image through each filter, one at a time.25 www.icodermag.com 01/2011
  • 25. THe All neW ios 5 WHAT’s neW In ios Each filter has it’s own parameters and can be queried All you do is determine whether the device can send in code to provide information about the filter, it’s pur- tweets, create an instance of the tweet sheet, attach pose, and input parameters. The system can also be any links or images, put some initial text and present queried to find out what filters are available. The most it modally. important classes in the Core Image framework: • CIContext. All of the processing of a core image is done in a CIContext. This is somewhat similar to a Core Graphics or OpenGL context. About the author: • CIImage. This class hold the image data. It can be manish nath creating from a UIImage, from an image file, or from I started iOS Application development almost 2 years pixel data. back just after my graduation. I was attracted to iOS instantly and tried to learn as much. I faced a lot of • CIFilter. The filter class has a dictionary that defines problems at that time with not a lot of forums to • the attributes of the particular filter that it represents. answer the queries and apple documentation being very crude. Now after having developed a variety TWITTer In Ios 5 of apps for different brands it is my time to give iOS 5 includes several ways to interact with Twitter. something back to the community. I have created The simplest, and possibly the one you will most likely this article taking references from different blogs implement, is the TWTweetComposeViewController. and putting them all together at one place for That name is quite a handful so we will affectionately developers to understand. call it “Tweet Sheet” just as Apple does. With literally Any querries are welcome at: just a couple of lines you can have a full tweet com- manish.nath87@gmail.com . poser within your app! You don’t have to worry about contacting the Twitter backend, handling user logins, or anything like that. Here is a code snippet for creating and presenting the TWTweetComposeViewController: if ([TWTweetComposeViewController canSendTwe- et]) { TWTweetComposeViewController *tweetSheet = [[TWTweetComposeViewController alloc] init]; [tweetSheet setInitialText:@”Initial Tweet Text!”]; [self presentModalViewController:tweetSheet animated:YES]; }26 www.icodermag.com 01/2011
  • 26. securITY Top errors and risks in ios – should be addressed by the developers! Krzysztof Wołk These days, you can find several types of mobile applications that are found in the market. With the advent of these new applications, several threats are also coming into the act and make it really tough for the end users to negotiate with them. There are also a few things that you should know if you love to use different types of mobile applications. There are certainly some risks as well as errors involved with them, which you should know to make correct implementations. In order to get rid of these issues, now security teams as well as development teams are constantly offering more importance to understand and known the most common security issues with iOS. Understanding the problem and finding the best way to negotiate with it can really offer you a good opportunity to make the correct use of the mobile applications. Well, you should make the correct assessment about the top errors and risks in iOS by knowing them through a professional perspective. If you use some of the most advanced as well as sophisticated mobile applications, then you should know these risks and the methods to mitigate such errors for iOS. In this regard, you can now follow some of the most useful steps in order to mitigate these issues further. Keep in mind that, these are the applications and they may come across some sorts of errors as well as risks. So, mitigating them is often important. Insecure sTorAGe oF dATA: sophisticated hardware. This sort of mechanism is also referred This sort of risk often addresses the kind of data we use to as the best Data Protection. Apple has often performed this in store within our mobile devices. Data may be important or two different ways that are often straightforward on the use. less important but storing them with the mobile devices can Passing through the right option can be determined in this fash- always generate the risk factor. Persistent storage of data with ion – NS Data Writing File Protection Complete towards the the mobile is often considered to be a critical issue. Some peo- NS Data Write to File:options:errors. In this way the file will ple make a practice of it and they may come across serious stay protected as well as encrypted in the right manner even consequences, if the mobile device uses to come across certain when the mobile device has been locked. If you wish to opt for errors with the applications. Due to such reason, an application an alternative mean, then you can always opt for the MS File developer should carefully look for the ways to design such ap- Manager set Attributes: ofltemAtpath: error and pass through plications that can help the end users to store data with their the NSFileProtectionKey that uses attributes with NSFilePro- mobile devices in a secure way. If the data storage option avail- tectionComplete and offers the right value to protect existing able with the mobile is critical enough, then it can also ham- data or files in the mobile device. In order to know about how per the overall functionality of the applications used for it. If to implement the common application behaviors, you can refer the application used for the mobile device is critical, then the to the Internet as well. However, the use may require the pass data shouldn’t be stored in the right manner. If the data is re- code in order to perform this task. iOS 3.x on the 3G as well ally important and highly sensitive, then it should be kept in as older devices don’t have this ability and they often require the most secure way. As far as data protection is concerned, it an enhanced effort. They are less secure but the most user often addresses Encryption. For some of the iOS developers it friendly solutions. is not considered as the onerous issue. If you will look for the leading one in this business like Apple, then you can find that dATA ProTecTIon lAcks durInG it has offered the most secure, easy to use and flexible data dATA TrAnsIT: protections features for the iOS 4. At the same time, the new After the data is stored in the device, the next big concern that devices are making the correct use of 3GS or some of the most may appear before you is to protect data at the communication27 www.icodermag.com 01/2011
  • 27. ToP errors securITY And rIsks In Ios... level among the applications on the mobile device and a server FAIlInG To ProTecT THe resources WITH or computer. Till some time the most popular communication THe HelP oF sTronG AuTHenTIcATIon: protocol announced for the market is known as the HTTP. This sort of issue is often connected with the server as well However, for the iOS developers, this typically means to use as with the client. It is also based on the server and client the NSURL. In this regard, the developers are also using the relation that often triggers a wide range of discussions in this NSURL connection class. However, the NSURL as well as the field of industry. As far as the mobile devices are concerned, NSURL connection class may fail if there is an error occurring a very small amount of authentication has been performed during the event as far as a SSL connection issue is concerned. for them. However, the major authentication solution that As far as the development team is concerned, they do not mobile devices encounter is based on a server that is used usually take advantages of the valid SSL certification and that to authenticate the mobile application. Applications on the seems to create a big problem. It’s the behavior of the NSURL mobile devices are authenticating other services in a straight as well as the NSURL connection that has been changed a lot forward manner very rarely. If this uses to occur directly, then in order to accept the invalid certifications. This also helps the the application will be asked to share the right resource like development team to perform their work without any hassles an image or the pieces of the data that have been managed further. When the NSURL connection is implemented, the through the application and in the server. The prime concern concerned application has to adopt some of the most delegate often stays with the iOS under such condition. As per this methods like canAuthenticateAgainstProtectionSpace as well scenario, the iOS applications may authenticate the server. as the didReceiveAuthenticationChallenge in order to prevent This also helps the server to implement some of the most or ignore the issues that SSL can generate. Implementation of robust authentication process that can uniquely identify the these issues can even trigger the opportunity to make the user mobile applications and their users on the server. However, concerned during the event of an invalid SSL certification. How- the prime concern for the developers is that they don’t have ever, the best method or practice is to fail the error so that to embed the secret of client with their application and to use the user will not be further able to accept the production de- them as the integral portion of the authentication method. velopments. There are also some conditional codes, which are never compiled for the production of binaries. These binaries FAIls In ImPlemenTATIon oF mInImAl often exclude the risky codes as well. However, this is the best PrIVIleGe AuTHorIzATIon: practice to ensure all the production codes are having develop- Only the request of permission is required for obtaining or ment based SSL codes that are pruned out. In short, you can accessing the local side things. Well, here, the question may say that during the development you have to perform actively rise if that does the application you use to require an access while making the insecure iOS. to the GPS of the users? Well, this often falls along to the line that uses to protect user’s private data. These lines are also leAkAGe oF PersonAl dATA: sensitive and often work to protect user’s sensitive data in a However, this is often considered as a less of the technical good way. While accessing the resources, you have to stay issue and has been considered as a perfect as well as purpose- really careful. The next part of this iOS issue is the server- ful selection that should be made by a developer. Developers application based. The prime issue is the handling of applica- should stay concerned about safeguarding the user’s private tions. Especially the thick applications that are related to the details and personal information. Applications should be de- client are often considered as the big matter of concern. This signed in the best possible way to protect user’s data. While may comprise a wide range of functionalities, which may not using the same sort of data protection techniques discussed in be available in order to lower the privileges of the users. The the previous risk, user’s personal data can be protected with server often stays responsible in order to check whether or the best mean. Apart from this it is considered as the applica- not the user can perform the requested action. Even though tions design based decision. This often helps the developers the functionality has been accessed through the application, to determine the best way through which user’s personal data it should not be allowed by the sever. If the server allows it, can be stored and protected. As far as personal data protec- then user’s privileges will be neglected. If the server will not tion and privacy is concerned, this has been considered as the allow it, then a higher level of user side privilege will be trig- most debatable topic nowadays. These days, users are really gered in terms of functionality at the server side. However, becoming aware about the fact that storing personal data in the vertical escalation of privileges is often considered to be, the mobile devices may make the right call for data loss or a risky business for the server side applications. At the same similar threats. This can really generate serious consequences time, horizontal privileges often allow users of the mobile ap- further as well. plications or devices to circumvent the authorization controls28 www.icodermag.com 01/2011
  • 28. ToP errors securITY And rIsks In Ios... easily. Users can even access the required data that belongs string. From the NS objective-C environment perspective, to other users operating at the same sort of privilege level. it rarely feels like the writing codes could be complied down However, proper care should be taken in order to increase with the native instructions. While moving for the SQLite you the accessibility of the mobile applications at the server side can find the illusion that often shatters quickly. For the format that is related to the user who is currently authenticated. strings % @ are used, as formatters that are often considered to be vulnerable to a wide range of interesting attacks. clIenT sIde InJecTIon: As far as client side injection is concerned, it is considered clIenT sIde dos: to be an interesting issue that can trigger a wide range of Client side DoS is an iOS issue that is quite apparent. While problems that often depend on the applications and their looking at this issue, first you have to ensure yourself as the functionalities. It also depends on how the applications use most defensive programmer. This sort of issue can be trig- to operate. There are some iOS applications that often utilize gered due to the errors in development as well as due to the SQLite, which exactly suggests that at a definite level such bad logic. As far as the modern mobile applications are con- applications will become more vulnerable for the injection of cerned, they can perform a lot of format parsing like XML SQLite. However, the consequences often found during the as well as JSON. However, the defect with these parsers can SQL injection at the client side are minimal. If you look for the even results into quite unexpected DoS. This sort of situa- recent vulnerability with the Skype client used for the Mac, tion may come into the act when these parsers are used in which is an iOS app, it may suggest you the possibilities of the a wrong way as well. RICH USER ENVIRONMENT as well as the consequences they can be even triggered when the application absolutely THIrd PArTY codes THAT Are mAlIcIous: trusts the input. This sort of vulnerability is often considered In this regard, we should start the discussion with an example. to be loaded with the simple and cross scripting that can pos- Let’s take JailBroken iPhone as an example. Let us assume it sibly attack the allowed remote codes, which are executed. again. Take JailBroken as your device and start to perform ac- Similar sorts of issues can also be surfaced for the mobile cordingly. Even for the legitimate devices like non jail-broken, applications if those applications use UIWebView. These appli- you can find some of the most interesting iOS errors that can cations are also found to use the rich environments and they be triggered. These errors are often related to the URL or the often don’t check the user’s input. These applications cannot protocol that uses to handle the whole mechanism. As far as even check the other inputs. iOS is concerned, it is not that big on the Inter Process Com- However, this sort of mitigation often fails down the stand- munication. There are several mechanisms available for iOS ard validation of the data. Any sorts of specific advice offered developers through which they can perform the URL scheme regarding this needs to be very specific so that they can be and can make it even more customized. However, developers useful in a common way. In this regard, first you have to en- should use these mechanisms with a lot of cautiousness. Keep sure that the data should be of specific length and always as in mind that there are malicious websites or called as external per your expected format type as well as range. Well, the resources that can make the right call for these errors. How- length for this sort of data is quite obvious. However, the ever, the behavior of the multiple applications is often tough to range should comprise of positive integers and equipped with define. The same scheme is still undefined. The fact is that you the expected numerical options. Data type can be of any type cannot really prevent an application when it tries to usurp the of integer or it can be structured in a manner so that other scheme you have added. As per iOS 4.2, there is always a bet- data can be read. The format is meant for the real source of ter and most advanced mechanism available which is known data formatting like the phone number. as IPC. It is also defined in this fashion - application: openURL: Well, data type is really an interesting topic to cover. If there soruceApplication: annotation. If you are required to perform are any NS objects that are inherently insecure, then they the IPC, then you are always allowed to use this method. With should not be trusted by the remote source. Well, the similar this you will also be able to overcome the real object while sort of approach can be maintained with the NIB files which not hacking them for the format that is ready for the URL. are also known as the serialized objects. They should be used In this regard, you should avoid trusting the serialized objects. locally and have to come only from the trusted sources. If the This is not a good idea to trust these objects. user can directly input these objects into a system and regu- late them as per the requirements, then a wide range of secu- buFFer oVerFloW AT clIenT sIde: rity bugs will develop which are often tough to catch or trace. Well, this is still a possible act. As the objective C uses to The next interesting aspect often remains in the format stay strictly superset of the element C, there is no limit,29 www.icodermag.com 01/2011
  • 29. ToP errors securITY And rIsks In Ios... which will be created at the depth. This can really make approach. This will help in deciding the security postures the right call for an iOS to find itself in more problems that the application often possesses towards the storage that can be generated due to the issues with the old C of data. If the risk can be determined, sensitive data can programming. You may not belabor them, but they are pos- be protected while allowing it to reside in the device. This sible on most of the occasions when this uses to happen. can be performed while using the best cryptograph, which In this regard, you have to pay a lot of attention towards is strong enough. the string formatting known as NSLog, etc. always try to stick with the hierarchy of NS class whenever possible for creATInG A secure communIcATIon you. You should abstract the C code and keep its size as WITH THe serVer: small as possible for you. You are always required to stay Most of the applications that are used to handle user’s data cautious about the C string as well as the memory opera- can be connected back to the server components. Due to tions. Failure to apply or address the server side controls is such reason, developers are often facing the challenge for an interesting error and to know more details about it you protecting client’s sensitive data, which is in transit phase can refer to the OQSAP. and during when that uses to travel on the web. Such data After the release of iPhone by Apple during the year can also travel through an insecure wireless connection. 2007, it has managed to become one of the most dominant This can be done while making the right use of encryp- forces in the mobile market or industry. In the year 2010, tion. Well, this should be implemented perfectly in order it has managed to acquire near about 21.3% of the whole to keep the data secure. As far as effective encryption is mobile market. However, the announcement of iPhone concerned, it is often based on the fact like avoiding the has also seen a few security issues on the go. If you look reinvention of wheel and using the trusted libraries that are for the recent past, then you will find that a constant ef- reviewed thoroughly. fort has been provided for the jailbreaking in order to gain full control of it. Unlocking the iPhone and allowing it to PATcHInG THe APPlIcATIon: get used for other GSM providers has managed to receive The Appstore may appear as a real enemy before you. a constant development. The security issues that are relat- Tolerance of risk requires to be conducted in order to de- ed to the iPhone often focus on its own platform and due termine the policy and whether or not it matches up with to this a very less percentage of attention has been offered the other applications. Apple has a tight grip on the App- to other applications in the way or at the app store. So, store and due to such reasons this is not often possible to what are the common iOS errors and risks that are affect- issue the release. Well, the organization can really do very ing its platform? Developers should understand and know less for the risk that is often associated with the problem. these risks or errors before they design any applications. THe PlATForm: sensITIVe dATA WHIcH HAs remAIn iOS security errors are also related to the user’s awareness unProTecTed: in a great way. Users may perceive as well as treat their Mobile applications are designed in a manner to offer us- mobile devices in a different way. They may show less care ers what they exactly require. Mobile users often require for these devices with comparison to the laptops and desk- the simplest applications which they can use on the move tops. They may lack to add the passwords that can possi- as well. With most of the applications, displaying, data bly protect the data on mobile devices. This often triggers storage, and storing sensitive data like features are added. a low level of security mean. That means a user can easily Some of the applications are also equipped with facilities loss his or her mobile device to malicious acts and the data like storing business details and displaying them in a great on the device may be compromised. fashion. Definitely, these applications make our life easier but at the same time developers shouldn’t avoid the iOS risks and errors that can produce potential harm for the About the author: data stored with these applications. In order to keep the data secure and out of reach from the malicious adver- krzysztof Wołk sary, developers are now required to offer an enhanced Graduate and doctoral student of Polish and Japanease importance towards both users as well as application sup- Institute of Technology. The holder of numerous cer- plier. The most suitable solution for this is to develop ap- tificates of Apple and Microsoft. IT training professional plications very carefully and there should be a risk-based coach, with a passion of a photographer.30 www.icodermag.com 01/2011
  • 30. reVIeW siri –Worth the Hype? Alex Allegro Three men took the stage in Cupertino back on Octo- that matter). Something this great deserves to be every- ber 4th. Phil Schiller, Scott Forstall and Tim Cook, the where possible, but thats just not the way Apple works. newly named CEO of Apple. The world was expecting the Sure there are plenty of ways to get Siri on your 4, 3Gs, iPhone 5, but that’s not what we got, we got the iPhone iPod Touch 4G and iPad, you just need to jailbreak! Today, 4s. While it wasn’t quite as feature packed as we hoped a port that claimed to be a full and legit port of Siri turned for, it sure was still pretty packed. The 8MP camera was out be an epic virus. Stealing data and breaking/bricking nice, and so was the new A5 processor. But what held the phones. Unfortunately, many people fell for this. So is Siri spotlight that day was a software feature. Exclusive to the really worth this much hype? Surly it couldn’t be that good, 4s, Siri shined that day. As described by Apple, Siri is “Your right? But then again, people are risking their phones just intelligent assistant that helps you get things done just by in hopes of getting a small little feature on their phone. asking”. To bloggers on the other hand, it’s just catching up So what is it? Well, from first hand experience, I can say to the competition. Android has had this built in for years, one thing. Siri is never wrong. No matter how fast you talk, and Windows Phone has had a voice control system since or how stupid the thing you say is, Siri will answer exactly 7.0. So what makes this so special? It it because Siri has what you say. Just like a video from a Microsoft employe the usual “Apple Polish” we find on all their products and testing Siri vs Mango’s version of voice comments, Siri was features? I think it has to do with the fact that it’s more right every time while Mango was wrong every time. than just a voice activated assistant. It’s the fact that it’s an As soon as these other systems start to listen just as AI. Asking your Android phone “What’s the weather like?” good as Siri, what will give Siri the advantage? An open API. Will probably return you with a “Sorry, I did not get that, The app store, with the most apps of any other application please repeat your command.” So why does it matter if we market, also has the most developers. So, if Apple opens can have conversations with our phones? Ask them ques- the API, the possibilities would be endless. tions freely? It’s so we don’t have to follow a set of rules. So, all in all. Is Siri really worth an upgrade? If you’ve So we don’t always have to make sure we ask questions we never owned an iPhone before or you have the 3Gs or 3G, want the correct way. Siri is something different, ask is it then yes, upgrade now, but if you own a 4, or any other de- “Sunny today?” Or “Can I wear a T-shirt?” will both return cent Android powered smartphone, I recommend you wait you with a “Yes, it’s looking nice in New York this week- until Apple does what they do best...and that’s amaze us. end.” Siri is more than any voice control system can dream to be, and I’ll tell you why. About the author: I’d bet a lot of money that right after Siri was announced, many people were “Ooooh-ing” and “Ahhhh-ing” at their Alex Allegro computer screens. I’d have to admit I did the same thing Is a young, aspiring tech writer who loves to write re- too. It blew my mind, especially since I was someone views and articles. He loves his Galaxy S II but can’t put who always was saying to my Android phone “Text Sam” down his iPod Touch either. You can find his work on and then I’d remember I ‘wasn’t allowed’ to say “Text”. “Allegrotechie.com” where he writes with his co-writer. I was only allowed to say what this phone only understood If you can’t find him on his sofa writing, you can find him which was “Message”, not “Text”. It was troublesome to at technology shows through New York. me, but I got over it. Always have I thought in the back of my head though “Boy, what if we could just say what- ever we wanted to our phones?” To me, it just made sense if we were able to get some sort of AI on our phones. Siri really delivered, but there are still a lot of downsides. One being it’s exclusive to the 4s. Of course, we all know good and well how Apple works, and until it rains fire, Siri won’t officially port over to the 4, 3Gs, or iPad (iPad 2 for31 www.icodermag.com 01/2011

×