Showing posts with label iPhone. Show all posts
Showing posts with label iPhone. Show all posts

Wednesday, July 10, 2013

Learning on Accessibility for the iOS Platform

According to Apple's Accessibility Guide for iOS, you should make your iPhone application accessible to VoiceOver users because:
  • It increases your user base. You've worked hard to create a great application; don’t miss the opportunity to make it available to even more users.
  • It allows people to use your application without seeing the screen. Users with visual impairments can use your application with the help of VoiceOver.
  • It helps you address accessibility guidelines. Various governing bodies create guidelines for accessibility and making your iPhone application accessible to VoiceOver users can help you meet them.
  • It's the right thing to do.
As of iOS 3.0, Apple has included the UI Accessibility programming interface, which is a lightweight API that helps an application provide all the information VoiceOver needs to describe the user interface and help visually impaired people use the application.
I had recently given a presentation on my Learnings on Accessibility for the iOS Platform at an internal event at Intuit, which I wanted to share with all of you.  It provides an overview on what it means to make an app accessible for the iOS platform. It also provides guidelines for making your iOS app accessible and includes an overview on the most common accessible attributes, traits and how to add Accessibility via interface builder as well as in code. It covers Accessibility Notifications, VoiceOver specific API, Accessibility Containers, and some of the best practices for Accessibility.
 
If you find the presentation helpful in making your iOS app accessible, feel free to send me a comment!  
Enjoy making your iOS app accessible!

Friday, March 8, 2013

Implementing Singletons for the iOS platform

The Singleton design pattern is one of the most frequently used design pattern when developing for the iOS platform. It is a very powerful way to share data across different parts of an iOS application without having to explicitly pass the data around manually.

Overview

Singleton classes play an important role in iOS as they exhibit an extremely useful design pattern.  Within the iOS SDK, the UIApplication class has a method called sharedApplication which when called from anywhere will return the UIApplication instance that is associated with the currently running application.

How to implement the Singleton Class

You can implement the Singleton class in Objective-C as follows:

 MyManager.h


@interface MySingletonManager : NSObject {
    NSString *someProperty;
}


@property (nonatomic, retain) NSString *someProperty;

+ (id)sharedManager;

@end

MyManager.m

#import "MySingletonManager.h"

@implementation MySingletonManager

@synthesize someProperty;

#pragma mark Singleton Methods

+(id) sharedManager {
    static MySingletonManager *sharedMySingletonManager = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        sharedMySingletonManager = [[self alloc] init];

    });
    return sharedMySingletonManager;
}
                  
- (id)init {
    if (self = [super init]) {
        someProperty = @"Default Property";
    }
    return self;
}

- (void)dealloc {
    // should never be called, but included here for clarity
}

@end

The above code fragment defines a static variable called sharedMySingletonManager which is then initialized once and only once in sharedManager.  The way that we ensure that it is only created once is by using the dispatch_once method from the Grand Central Dispatch (GCD).  This is thread safe and handled entirely by the OS so you do not need to worry about it at all.

If you rather not use GCD, then you can the following code fragment for sharedManager:

Non-GCD Based 

+ (id)sharedManager {
    @synchronized(self) {
        if (sharedMySingletonManager == nil)
            sharedMySingletonManager = [[self alloc] init];
    }
    return sharedMySingletonManager;
} 
 
Then, you can reference the Singleton from anywhere by calling the function below:

Referencing the Singleton

MySingletonManager *sharedManager = [MySingletonManager sharedManager];
Happy Singleton'ing!   If you find this post useful, then mention me in the comments.

View more documents from tasneemsayeed.

Friday, May 6, 2011

Just Released: FREE Sudokroid (Sudoku Game Puzzle) in Android Market

More than 10 billion apps have been downloaded since the launch of the Apple (NSDQ: AAPL) App Store—the majority of them via iPhones.  As of March 2011, 37 percent of mobile consumers who owned a smartphone had a device with an Android OS. Apple’s iOS, claimed by 27 percent of consumers, is now outpacing Blackberry, which has 22 percent of the market.


It only seemed appropriate that one of the first mobile apps I decided to release was an Android app, Sudokroid, to the Android Market. Sudokroid is a logic-based number placement puzzle, which initially starts with a partially completed 9x9 grid. The game provides the player with the options to start a "New Game", "Continue" an existing game, an "About Game" option to get further details for playing the game, and finally "Exit Game" to exit from the game.  




When the player selects a "New Game" , it will let the player select the difficulty level from a choice of 3 levels: "easy", "medium" and "hard". A new game grid is displayed, partially filled, while splendid soothing music is playing in the background!  If "Continue" is selected, then the game continues from the previous game state.



The goal of Sudokroid is to fill the grid so that each row, each column and each of the 3x3 boxes contains the digits 1 to 9 exactly once.  Hints are provided to help in the selection, and if a selection results in "no move", then the player can go back to the previous tiles and revisit some of the prior moves.

You can download the game for FREE from the Android Market from http://bit.ly/mO8qfE.  Be sure to rate it and tweet or leave me a comment !  Stay tuned for more apps in the pipeline!

Friday, November 12, 2010

iPhone Game Design Challenges

As Ernest Adam writes in "The Fundamentals of Game Design":
"Good games and game worlds possess harmony, which is the feeling that all parts of the game belong to a single, coherent whole. This quality was first identified by game designer Brian Moriarty. "

An excerpt from his lecture, "Listen: The Potential of Shared Hallucinations, (Moriarty, 1997) Moriarty explained the concept of harmony as follows:

Harmony isn't something you can fake. You don't need anyone to tell you if it's there or not. Nobody can sell it to you, it's not an intellectual exercise. It's sensual, intuitive experience. It's something you feel. How do you achieve that feeling that everything works together? Where do you get this harmony stuff?"

Not surprisingly, there are several challenges for designing games on the iPhone :

  1. The screen size is small (320 by 480 pixels). This small space leaves very little room for top header displays or menus during game play.
  2. Multitouch Interface
    • The multitouch interface on the iPhone has opened new and exciting user interface design opportunities. When the iPhone was introduced, it was completely revolutionary with its touchscreen interface that supports and can track multiple touches simultaneously.  This user interface breakthrough, and intuitive and innovative interface enhances the creativity in touchscreen gaming. It has already resulted in a total paradigm shift in the way designers now approach an iPhone game.
    • The ability of the iPhone interface to detect swipes and pinches gives us new ways of differentiating and responding to user input.
    • Instead of using buttons to zoom in and out of a game level, you can allow the user to zoom in and out using a pinch motion
    • Users can also take a look around a particular level just by swiping their finger across the screen to control the direction that the camera will pan
  3. Limited screen size has resulted in inspiring game designers to select novel control schemes. For example, you can use the built-in accelerometer to tilt or steer characters or other game objects instead of putting controls on the screen
  4. The accelerometer can also be used for detecting shakes or movements. This can be used in games to trigger an action or to reveal a hidden surprise
  5. The iOS Location Service (Core Location Framework) is a major feature that is typically overlooked by many game developers. The Assisted GPS (A-GPS) in the iPhone 3G can be used in many creative ways.  You can use it to control a user's motion during game play or to identify other users who are playing the game nearby. Also, once other game players nearby are identified, they could be sent invites to meet at a specific location for other social interaction (i.e. chatting, meeting in a photo gallery, playing other games, etc).

Saturday, October 30, 2010

iPhone: Tips for Extending Your Battery Life

After using an iPhone for a few days, you may discover that while these devices are very innovative, intuitive and fun than perhaps most other smart phones, they do not excel in battery life. Any dedicated serious iPhone user will surely need to recharge his or her iPhone almost on a daily basis.

There are ways to conserve your iPhone battery life, but many of them involve turning off services and features, which make it a choice between all of the cool things that the iPhone can do and making sure that it can retain sufficient juice to do them.

Here are some tips to help you extend your battery life:

  1. Dim the screen. Touchscreen drains the battery, so the brighter the default setting of the screen, the more it drains the battery, so reducing the brightness will conserve more of your battery. You can find it in Settings -> Brightness
  2. Cycle the battery. All Lithium-based batteries slowly loose their charging capacity over time. Let it completely discharge and then fully recharging it again.  To maintain optimal performance, you should cycle your iPhone or iTouch's battery every one or two months.
  3. Turn data push off. The iPhone 3G can be set to automatically push email and other data down to it whenever new data becomes available. Every time you access the networks, it costs you battery life, so turning off push will help to extend your battery life. When push is turned off, you will need to check your email periodically (see #4 below).
  4. Fetch email less often.  The more your iPhone needs to access the network, the more it consumes the battery. So, set your iPhone to check for new email less often (i.e. every hour or so). Or, ideally, set it to "Manual Check". You can find it in Settings -> Mail, Contacts, Calendar ->Fetch New Data.
  5. Turn Bluetooth off except when you are using it. Bluetooth wireless network is useful for users with wireless headsets or earpieces. But, transmitting data wirelessly requires juice, and leaving it on all the time can drain the battery even more. Turning off Bluetooth except when you are using it will help you conserve battery life. You can find it in Settings -> General.
  6. Turn off 3G if you are using the iPhone 3G and not downloading web content. The iPhone 3G operates on two cellular networks, EDGE and the faster 3G. Not surprisingly, using 3G requires more battery to get the faster speeds and the higher quality calls. It may be tough to go slower, but if you need more battery life, then turn off 3G and just use EDGE. You can find it in Settings -> General -> Network.
  7. WiFi is another high-speed network that the iPhone supports, which is even faster than 3G, though it is only available where there is a hotspot, not everywhere like 3G. The drawback is that if it is always enabled, it can quickly drain your battery life. Unless you are using WiFi right now, keep it disabled. Find it in Settings -> WiFi.
  8. Turn off Location Services unless you are using it right now. The built-in GPS is one of the coolest features of the iPhone 3G, which allows the phone to know where you are and gives you exact driving directions and gives that information to applications that can help you find nearby restaurants, etc. But, like any other service that requires network access, it needs battery life. If you are not using location services, then turn it off and save some battery power. You can find it in Settings -> General.
  9. Set your iPhone to 'auto-lock' sooner.  You can set your iPhone to automatically go to sleep sooner (aka Auto-Lock) after a certain amount of time. The sooner it sleeps, the less power is used to display the screen or other services. You may try setting it to 1 or 2 minutes. You can find it in Settings -> General -> Auto-Lock.  In the case of an iPad, you can put it into sleep mode when not in use by manually pressing sleep/wake button.
  10. Minimize your tasks (i.e. avoid background music) or running applications that require the phone to run for a long period of time or use up a lot of resources such as playing videos, games, browsing the web, etc. can use up a lot of battery power. If you want to conserve battery power, then limit the use of battery-intensive apps.