Category Archives: Ios

Knowing Memory Usage in iOS

This task is quite straightforward. First, import the following headers:

#import <mach/mach.h>
#import <mach/mach_host.h>

Now what?. Simple… use this method:

-(void)printMemoryUsage
{
    mach_port_t host_port;
    mach_msg_type_number_t host_size;
    vm_size_t pagesize;

    host_port = mach_host_self();
    host_size = sizeof(vm_statistics_data_t) / sizeof(integer_t);
    host_page_size(host_port, &pagesize);

    vm_statistics_data_t vm_stat;

    if (host_statistics(host_port, HOST_VM_INFO, (host_info_t)&vm_stat, &host_size) != KERN_SUCCESS)
    {
        NSLog(@"Failed to fetch vm statistics");
    }

    /* Stats in bytes */
    natural_t mem_used = (vm_stat.active_count +
                          vm_stat.inactive_count +
                          vm_stat.wire_count) * pagesize;
    natural_t mem_free = vm_stat.free_count * pagesize;
    natural_t mem_total = mem_used + mem_free;

    NSLog(@"used: %u free: %u total: %u", mem_used, mem_free, mem_total);
}

Credits: This is a snippet taken from this Stackoverflow question.

Free iPhone MAME Emulator

iPhone mame

From time to time, Apple’s Review Team, for whatever reason, allows Apps that clearly violate the AppStore guidelines.

This time, Gridlee managed to got in. It’s free, and it’s somewhere around 85 megabytes. You can expect it to be removed sooner rather than later… so my recommendation would be… go and get it!.

You can install any ROMs you might have already downloaded. Playing Choplifter on an iPad Retina isn’t hi-tech, but i’ve always said, old school games are the best. You don’t need complex 3d algorithms, shadows, or near-perfect water effects to have fun.

After all, it’s all about getting rid of the bad guys… right!?

New iPhone Jailbreak!

iphone-jailbreak

Today, a new iPhone Jailbreak solution, has been announced to be already on its way. iOS 6.0 and 6.1 beta 4 have been both jailbroken, and the team is waiting for iOS 6.1 final release to launch the goodies!.

If you have a previous iOS version, and you still wanna jailbreak your device, you should head to this site. They have a nice archive of every JB solution that got released.

By the way, Jailbreaking an iOS device is completely legal. However, downloading illegal copies of iOS Apps is not cool, and we recommend you do not engage in those activities.

Support the developers..!!

Top 5 iPhone Games

Do you usually spend time waiting for a bus… without anything to do?. And how about when there is nothing on TV? what do you do?. Or… say… you’ve just finished that book you’ve been reading for months, and you have no clue what to do with your spare time!.

If you answer ‘yes’ to any of the above questions, then this short list of Top 5 iPhone Games is just for you!.

Fix It Felix Junior, the game!
Fix-It Felix Jr.
I fell in love with this title. It’s a simple old-shool videogame, in which you need to fix the building, while Wreck-It Ralph breaks everything. It took me about 5 minutes to get used to the onscreen controls… you should give it a shot!.

 

 

Grand Theft Auto for iPhone
Grand Theft Auto, Vice CIty
Ahhh… who didn’t get to play GTA 1 on an old Pentium PC?. And how about GTA 2?. Well… guess what… GTA has reincarnated as an iOS videogame. It’s about 4.99 dollars, but it’s worth every penny. Most definitely!

 

 

Talking Carl for iOS
Talking Carl
What can i say about this…. Red, as i call it, is my friend. He’s not smart as Siri, so.. he will just repeat whatever you say. But it’s really fun… and kids do love him. Download it, and tickle him. It’s worth it!

 

 

Tesla Toy iPhone Game
Tesla Toy
Do you own a Tesla Coil?. Me neither. But i do have an app that looks the same way, so to speak. This app emulates the behavior of a Tesla Coil. You should see it running on an iPad, it’s pure eye candy.

 

 

Talking Ted iOS Game
Talking Ted (Lite!)
This app doesn’t compete with Talking Carl, since Ted doesn’t repeat whatever you say. However, since Ted is a talking bear, this app has a couple recordings of the toy, doing several things (such as drinking alcohol). The lite version is free.. so… give it a shot!

 

 

Using NSLocalizedString with a dictionary stored inside a bundle

We’ve seen before how to create an iOS Assets bundle. Today, we’ll try to localize a string, using a dictionary stored in a bundle. In order to do so… we’ll rely on the following helper method:

@interface LABundles
+ (NSBundle*)someResourcesLocalizationBundle
@end

@implementation LABundles
+ (NSBundle*)someResourcesLocalizationBundle
{
    static NSBundle* someResourcesLocalizationBundle = nil;

    if ( someResourcesLocalizationBundle == nil )
    {
        // This double check increases efficiency. Don't you get bored of asking the same thing twice?.
        @synchronized(self)
        {
            if ( someResourcesLocalizationBundle == nil )
            {
                // Figure out the current language.
                NSUserDefaults* defs = [NSUserDefaults standardUserDefaults];
                NSArray* languages = [defs objectForKey:@"AppleLanguages"];

                NSString* currentLanguage = [languages objectAtIndex:0];

                // Map the current language's folder within the bundle
                NSBundle* bundle = [NSBundle someResourcesBundle];
                NSString* path = [bundle pathForResource:currentLanguage ofType:@"lproj"];

                // Okay, let's go with the default bundle
                if ( path == nil )
                {
                    someResourcesLocalizationBundle = bundle;
                }
                // Bingo!
                else
                {
                    someResourcesLocalizationBundle = [NSBundle bundleWithPath:path];
                }

                [someResourcesLocalizationBundle retain];
            }
        }
    }

    return someResourcesLocalizationBundle;
}
@end

 
What’s that all about?. Well… it turns out that order to resolve localized strings, first of all we need to figure out what’s the device’s language.

After that, we need to load a NSBundle object mapped to the folder inside the bundle, which contains the localized strings file. And then we can begin talking about resolving a localized string.

The code pasted above has been tested, of course!. But how do you use it ????

Supposing that you need to localize the string ‘Testing1′, and that you intend to use a dictionary named ‘InfoPlist.strings’, you need to do the following:

[[NSBundle someResourcesLocalizationBundle] localizedStringForKey:@"Testing1" value:nil table:@"InfoPlist"]

Of course, you can customize that. If your dictionary file is named ‘Localized.strings’, you don’t even need to specify the ‘table’ parameter.

I hope you find this useful!