$aleOrigin

Please consider subscribing to Mobile Developer Tips
RSS feed or following us on Twitter


Sort A Dictionary By Value Of Each Key-Value Pair

You can sort the values in a dictionary using the method keysSortedByValueUsingSelector:. The result is an array of keys from the dictionary, which represent the sorted values of the key-value pair.

Let’s say for example that you have a dictionary that has key-value pairs with an account name and balance:

NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:
              [NSNumber numberWithDouble:-100.00], @"Account1",
              [NSNumber numberWithDouble:72.99], @"Account2",
              [NSNumber numberWithDouble:30.89], @"Account3",
              [NSNumber numberWithDouble:200.74], @"Account4", nil];


Continue reading this post »

Add Comma Separators to Numbers

Seems a common question, how can I format a number such as 123456 to look like 123,456? The NSNumberFormatter makes this quite easy.

NSNumberFormatter *formatter = [[[NSNumberFormatter alloc] init] autorelease];
[formatter setNumberStyle:NSNumberFormatterDecimalStyle];
 
double d = 234567.89;
int i = 1234567890;
 
NSString *strFloat = [formatter stringFromNumber:[NSNumber numberWithDouble:d]];
NSString *strInt = [formatter stringFromNumber:[NSNumber numberWithInt:i]];
 
NSLog(@"Float: %@", strFloat);
NSLog(@"Int: %@", strInt);

The output would look like this:

Float: 234,567.89
Int: 1,234,567,890


Continue reading this post »

Should MobileDeveloperTips.com Expand to Include Android?

Since August of 2008, this blog (formerly known as iOS Developer Tips) has focused on iOS application development. Long story short, the rename of the blog was to move away from trademarked names in the domain, artwork, etc.

One positive side-effect of the name/domain change is the opportunity to expand the site to include Android developer tips and tricks.

I’ve been rolling the idea around for some time, maybe this is the perfect segue. I welcome your comments, feedback and suggestions about this idea…

iOS Open Source : Semi-Modal View

Kent Nguyen has created a category that extends UIViewController, displaying another view which partially covers the current view. Take a look at the screenshot below to get an idea of how this looks. The original view (on the top) is partially hidden and the new view on the bottom is modal.



Continue reading this post »

Volume Control Alert

If you need a quick and dirty volume control, an alert specifically tailored for this purpose is included in the MediaPlayer framework. The alert looks as follows::

To display the alert, adding the following code and include the MediaPlayer framework in your project:

Continue reading this post »

SaleOrigin – Tracking From App Campaigns To App Installs

I’d like to introduce a new sponsor of Mobile Developer Tips, SaleOrigin.

SaleOrigin focuses on tracking how mobile app campaigns leads to installs, and also includes app analytics and app store data.

There are many ways to promote applications designed for smartphones:

- Your own blog or an affliated website
- Ad networks (Google Adwords, LinkedIn, etc)
- App review websites
- Advertising on popular and content related blogs
- Facebook, Twitter and other social networks

Question is, how can you track which promotional activities are the most effective? This is where SaleOrigin can help – through URL shortening, different links are used for each marketing channel or ad campaign. For example, unique links are generated for websites, ad networks, Facebook, etc. Using the SaleOrigin SDK you can track all links and their effectiveness. The end result is real information that can help you target your ads on the platforms and services that are delivering the most value.

Continue reading this post »

Get Image Data Including Depth, Color Model, DPI and More

Although you can get some basic information if you load an image into a UIImage object, at times it can be helpful to more about an image, for example, the color model (RGB, CMYK, Gray…), resolution in dots-per-inch (DPI), etc.

One way to gather such information is through a CGImageSource object. Often times this object is created using a URL, and once the object is known, you can get image data through a range of C functions (traditional C functions versus methods in an Objective-C object).

The image we’ll use for this tip is shown below:



Continue reading this post »

iOSDeveloperTips.com Is Now MobileDeveloperTips.com

iOSDeveloperTips.com has moved to a new domain: MobileDeveloperTips.com

I’ve tried to make the change as transparent as possible, including redirection and search engine notifications. With that said, there are new Twitter and Facebook pages.

Twitter is now located here: MobileDevTips

If you were following the previous Twitter account (iOSDevTips), there is no change required on your part. Unfortunately, Facebook does not provide a means to migrate fans, so there is a new Facebook page:

Facebook is now located here: Mobile Developer Tips on Facebook

Please take a moment and check your links to the blog, twitter and Facebook.

iOS Open Source : Circular Rotating Menu

CDPieMenu is an open source project that provides a configurable, circular control for menu selection. The look is similar to the rotating hardware control on the original iPod.

In the screenshot above I’ve set the control to contain 10 images, each the same (white arrow). The control handles the UI from layout of the images to momentum and image selection (when the wheel stops rotating). CoreGraphics is the engine behind the drawing of CDPieMenu.

Continue reading this post »

All Content Copyright © 2008-2012 • Mobile Developer Tips, All Rights Reserved.
iPhone and iPad are registered trademarks of Apple, Inc.
iOS is a registered trademark of Cisco Technology, Inc.