Showing posts with label iPad. Show all posts
Showing posts with label iPad. 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.

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.