Palo Alto home of late Steve Jobs burglarized

The San Jose Mercury News reports that the home of the late Steve Jobs was burglarized July 17, with “computers and personal items” being apparently stolen and possibly sold. No doubt the items stolen would have great value to some people if they knew whose family they were taken from. No word on whether all of the items taken were recovered.

This doesn’t appear to be a targeted event, however, as the prosecutor says the accused likely didn’t realize whose house he was robbing. The Jobs home is currently undergoing renovations.

Palo Alto home of late Steve Jobs burglarized originally appeared on TUAW – The Unofficial Apple Weblog on Tue, 14 Aug 2012 10:30:00 EST. Please see our terms for use of feeds.

Source | Permalink | Email this | Comments

Double, the iPad telepresence robot rolls around the office when you can’t

Get ready to see iPads zipping around your office. As a remote worker I’m fascinated by telepresence robots, or a remote robotic avatar which lives at an office and roams the halls under your control, typically interacting through a 2-way video chat tool. Naturally, Double Robotics took the iPad’s advantages and built what looks like a tiny Segway for the iPad to move about on, calling it the Double.

The Double mounts an iPad up top for communicating, has an adjustable height, and uses a second iPad for controls. The video below shows the robot in action. The iPad is almost perfectly suited to this task, being a lightweight but head-sized video communicator when needed.

It’s brilliant, minimal and will cost you US$2,499 by December. You can pre-order for $1,999 but the iPads aren’t included. The Double is quite reasonably priced for such a thing, as telepresence robots tend to be a specialized industry with units selling for $10,000 or more. Double Robotics may have a hit on its hands if the Double can stand up to the abuse of roaming around an office or industrial setting.

[via Core77]

Double, the iPad telepresence robot rolls around the office when you can’t originally appeared on TUAW – The Unofficial Apple Weblog on Tue, 14 Aug 2012 10:00:00 EST. Please see our terms for use of feeds.

Source | Permalink | Email this | Comments

Imo offers free voice calling for iOS users

The imo instant messenger app has been updated to add voice calls. The app can communicate with your friends on any almost IM network, including Facebook Chat, Google Talk, Skype, MSN, ICQ/AIM and more. With this latest update the app adds high quality voice calls.

To place a call, you tap a contact’s name, and you are connected. Callers can contact other imo users on iOS or on Android. There’s a video tutorial on the web.

imo requires a sign up. The app works on the iPhone and iPod touch and requires iOS 3.1 or later. There is a separate iPad app with the same features.

imo has a good following and generally positive reviews. This update should add to its popularity.

Imo offers free voice calling for iOS users originally appeared on TUAW – The Unofficial Apple Weblog on Tue, 14 Aug 2012 09:00:00 EST. Please see our terms for use of feeds.

Source | Permalink | Email this | Comments

HP Expert Day for Apple users this Wednesday, August 15

Apple has its geniuses; HP has experts. While you can go into any Apple Store and chat up an Apple Genius about issues you may be having with your iPhone, Mac or other product, it’s not often that you get the chance to talk to someone about a peripheral product like an HP printer or all-in-one. This Wednesday, HP is holding an Expert Day for Apple users who might have questions about how HP products work with their Apple devices.

Starting at 7 AM PDT and going until 5 PM PDT on August 15, you’ll be able to take part in a day-long session aimed at Mac owners as well as those using iOS and AirPrint for HP products and peripherals.

To participate and get support on in- and out-of warranty HP products, log into the Consumer Support Forum page (free registration here) and then point to the Mac Printing & Scanning Board. While posting your question, be sure to select the “Email me when someone replies” option so you’re alerted when the Expert addresses your question.

HP also announced that Mac users upgrading to Mountain Lion from Lion or Snow Leopard should have no issues following the upgrade. The company has Mountain Lion software updates available for the HP Deskjet 2510, Deskjet 3520, Officejet 4620, Officejet 6100, and Photosmart 5520 printers and all-in-one printers.

Continue reading HP Expert Day for Apple users this Wednesday, August 15

HP Expert Day for Apple users this Wednesday, August 15 originally appeared on TUAW – The Unofficial Apple Weblog on Tue, 14 Aug 2012 08:00:00 EST. Please see our terms for use of feeds.

Source | Permalink | Email this | Comments

$60,000 Worth of Computers and Personal Items Stolen from Steve Jobs Home

Steve Jobs’ Palo Alto home was burglarized last month, according to a report from Santa Clara County Deputy District Attorney Tom Flattery and MercuryNews. Suspects are now in custody for…

[[ This is a content summary only. Visit my website for full links, other content, and more! ]]

While waiting for a 1080p Apple TV Jailbreak the old jailbroken 720p gains in popularity

As people are waiting for the 1080p Apple TV to be jailbroken, the prices of the already jailbroken 720p Apple TV have risen immensely, the older Apple TV (new in box) is going for as much as $230 on Amazon and eBay, while the newer model with 1080p is going for as little as $90, on some sites. Those who want more features on their Apple TV are apparent willing to pay significantly more for an older version.

It does however seem as if there might be hope for 1080p Apple TV owners who are after the jailbreak features, according to someone within the jailbreak community a jailbreak for the third-generation Apple TV is indeed in the works.  Additionally, James Abeler of FireCore told 9to5Mac.com the following:

There is a group of very bright and talented individuals working on a lead that could result in a usable jailbreak for the 3rd gen Apple TV. While there is no telling how long this process could take, we remain optimistic that a jailbreak for this device will be available in the future. For the record, no one at FireCore is involved in the jailbreak discovery process.

We find it interesting that people are willing to pay three times the money for older hardware just so they can jailbreak it, what do you think? would you pay $230 just so you could jailbreak your Apple TV?

Open Source Unity 2D Game Framework With A Flash/Cocos2D Like Syntax

I’ve mentioned some excellent tutorials on developing 2D games with Unity.   Because Unity was not originally created for 2D games these tutorials use some additional libraries.

Today I came across a new framework from Matt Rix known as Futile for creating 2D games with Unity with a syntax similar to that used by the popular iOS game engine Cocos2d.

Included is a simple game demo and here’s a video illustrating Futile’s demo project in action on iOS and other platforms:

You can find the repository for Futile on Github here.

You can find out more about Futile, and find some tutorial videos on getting started on Matt’s site here.

A new framework still under development, but looks like it’s off to a great start.

DeliciousTwitterFacebookRedditLinkedInEmail


Custom Table View Cells in iPad Programming

The UITableViewCell class can be configured to display in a variety of standard ways, but sometimes we want to display content in a cell that cannot be fit into one of the standard display modes. In this blog, we’ll use a table view to display a series of customized cells. So, let’s get started!

Start Xcode, select “Create a new Xcode project,” choose the Empty Application template, and click Next. Name the project CustomCells, and select options as shown:

Click Next, choose a location to save the project, then click Create.

We’ll be adding two new files to the project, a UITableViewController, and a xib file for our custom cell.

Choose File | New > File… from the menu, and add a UITableViewController named TableViewController as shown:

We do not need a xib file for this controller. Click Next and save the file in the default location by clicking Create.

Again choose File | New > File… from the menu, and this time create an empty xib file by selecting Empty in the User Interface section:

Click Next, make sure the Device Family is set to iPad, click Next, and save the file as CellNib in the default location by clicking Create.

Open the CellNib.xib file you just created. Drag a UITableViewCell from the library to the empty surface of the xib file, then add labels to the cell as shown here:

Set the text and for the labels as shown. In this example, the font size of the first label is 27, and it is set to System Italic. All other labels have the default font and size.

The next step is to set a tag value for each label that still has the text “Label.” Set the tag value for the large italic label to 1, then set tag values of 2, 3, 4, and 5 for the remaining “Label” labels to the right of Address 1:, Address 2:, Phone:, and Cell:.

In order for the table view controller to find this xib and use it as a template for each of its cells, we’ll need to change File’s Owner’s class in the xib. Select File’s Owner, then in the identity inspector, change the Class to “TableViewController” as shown here:

In the properties of the actual cell, set the identifier to Cell. We’ll be returning to this xib file in just a moment to wire up the cell to a property in the TableViewController, but first we have to create that property.

Open TableViewController.h and make these changes to the file:

#import <UIKit/UIKit.h>

@interface TableViewController : UITableViewController

@property (nonatomic, strong) NSArray *cellContent;
@property (nonatomic, strong) IBOutlet UITableViewCell *customCell;

@end

In this demo, we define an array to hold the content of the cells. We also define a UITableViewCell as an outlet called customCell. Save the file, then return to CustomCell.xib. Wire the customCell outlet to the cell as shown:

Now open TableViewController.m and make these changes:

#import "TableViewController.h"

@interface TableViewController ()

@end

@implementation TableViewController

@synthesize cellContent, customCell;

– (NSArray *)cellContent
{
    cellContent = [[NSArray alloc] initWithObjects:
                   [NSArray arrayWithObjects:@"Alex Ander",
                    @"213 4th St.", @"Apt. 17", @"555-555-5555", @"111-111-1111", nil],
                   [NSArray arrayWithObjects:@"Jane Doe",
                    @"4 Any Ave.", @"Suite 2", @"123-456-7890", @"098-765-4321", nil],
                   [NSArray arrayWithObjects:@"Bill Smith",
                    @"63 Smith Dr.", @"", @"678-765-1236", @"987-234-4987", nil],
                   [NSArray arrayWithObjects:@"Mike Taylor",
                    @"3145 Happy Ct.", @"", @"654-321-9871", @"654-385-1594", nil],
                   [NSArray arrayWithObjects:@"Nancy Young",
                    @"98 W. 98th St.", @"Apt. 3", @"951-753-9871", @"951-654-3557", nil],
                   nil];
    return cellContent;              
}

– (id)initWithStyle:(UITableViewStyle)style
{
    self = [super initWithStyle:style];
    if (self) {
        // Custom initialization
    }
    return self;
}

– (void)viewDidLoad
{
    [super viewDidLoad];

    // Uncomment the following line to preserve selection between presentations.
    // self.clearsSelectionOnViewWillAppear = NO;
 
    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
}

– (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

– (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
        return YES;
}

#pragma mark – Table view data source

– (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    // Return the number of sections.
    return 1;
}

– (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    // Return the number of rows in the section.
    return [[self.cellContent objectAtIndex:0] count];
}

– (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 149.0f;
}

– (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
    cell.backgroundColor = [UIColor colorWithRed:1 green:1 blue:.75 alpha:1];
}

– (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
   
    if (cell == nil) {
        [[NSBundle mainBundle] loadNibNamed:@"CellNib" owner:self options:nil];
        cell = self.customCell;
        self.customCell = nil;
    }
   
    // Configure the cell…
    UILabel *textTarget;
    textTarget = (UILabel *)[cell viewWithTag:1]; //name
    textTarget.text = [[self.cellContent objectAtIndex:indexPath.row] objectAtIndex:0];
    textTarget = (UILabel *)[cell viewWithTag:2]; //addr1
    textTarget.text = [[self.cellContent objectAtIndex:indexPath.row] objectAtIndex:1];
    textTarget = (UILabel *)[cell viewWithTag:3]; //addr2
    textTarget.text = [[self.cellContent objectAtIndex:indexPath.row] objectAtIndex:2];
    textTarget = (UILabel *)[cell viewWithTag:4]; //phone
    textTarget.text = [[self.cellContent objectAtIndex:indexPath.row] objectAtIndex:3];
    textTarget = (UILabel *)[cell viewWithTag:5]; //cellPhone
    textTarget.text = [[self.cellContent objectAtIndex:indexPath.row] objectAtIndex:4];
   
    return cell;
}

#pragma mark – Table view delegate

– (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    // Navigation logic may go here. Create and push another view controller.
    /*
     <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil];
     // …
     // Pass the selected object to the new view controller.
     [self.navigationController pushViewController:detailViewController animated:YES];
     */

}

@end

After synthesizing the properties, we override the getter of cellContent to lazily instantiate it to an array of arrays of strings holding names, addresses, and phone numbers. Since there is only one section in this table view, the numberOfSectionsInTableView: method returns 1. The numberOfRowsInSection: method just returns the count of inner arrays in the cellContent array.

In heightForRowAtIndexPath: we must return the height of the cell in CustomCell.xib. If you are entering this code from scratch, your cell height will most likely be a different value.

In order to change the background color of a cell, we must define the delegate method tableView: willDisplayCell: forRowAtIndexPath: method. This is the only opportunity we have to alter the background color of a UITableViewCell’s underlying view.

The tableView: cellForRowAtIndexPath: method first attempts to get a reusable cell. If there is no cell (cell == nil), then we load the nib file from the bundle (which populates the customCell property), set the cell to the customCell, then set the value of customCell to nil (so it doesn’t remain on the heap). After this, we configure the labels on the cell using their tags. Each label’s text is set to a value in the cellContent array. At the end of the method, we return the cell.

TableView: didSelectRowAtIndexPath: is shown here, but not implemented. We would most likely push a new view controller in response to the selection.

Only one thing remains: we must set up the views in AppDelegate in order for them to be displayed in the window. Open AppDelegate.h and make these changes:

#import <UIKit/UIKit.h>
#import "TableViewController.h"

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) TableViewController *tableViewController;
@property (strong, nonatomic) UINavigationController *navController;

@end

Make the following changes to the application: didFinishLaunchingWithOptions: method in AppDelegate.m. Remember to synthesize tableViewController and navController in AppDelegate.m as well!

– (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    self.tableViewController = [[TableViewController alloc] initWithStyle:UITableViewStylePlain];
    self.tableViewController.title = @"Table View";
    self.navController = [[UINavigationController alloc]
                          initWithRootViewController:self.tableViewController];
    [self.window addSubview:self.navController.view];
    [self.window makeKeyAndVisible];
    return YES;
}

Now run the application, and note that the default cells in the tableViewController have been replaced by our custom cells:

Table View Cells created in this way can contain any control; they are not limited to containing labels and images only. Since File’s Owner is the TableViewController, any action methods must be declared and defined in the view controller class, and will need to detect which cell contains the control being interacted with. But that is the subject of another blog…

WTHR and Nubilous: Simple, Beautiful Weather Apps

When it comes to checking the weather on your iPhone, there are way too many solutions. You can use something like Wunderground to get the most accurate reports, or Weather 2x, a less precise and more beautiful alternative. Then there’s the boring old app that comes with your iPhone. It has a rather stale design and doesn’t offer many details, but that’s mainly because it’s taking a minimal approach to things.

Nubilous and WTHR are two minimal, but beautiful weather apps. Is one better than the other, though? Let’s find out.

WTHR

The first pick is “weather,” just shortened and stylized with capitals. Its name suggests simplicity, and that’s just what the app itself exhibits throughout. I did say that both apps are simple, and while that’s true, this happens to be the most minimal of the two.

Information Offered is Adequate, But Could Be Better

I said that both apps are minimal, but WTHR is actually more so than Nubilous. In fact, it doesn’t even support multiple cities. The developer wants to make sure that you get a nice experience that’s very, very simple and nothing more. I suppose this is a good thing for users who just want to take a quick look at what the weather currently is. WTHR offers little icons for sun, wind, clouds and other common conditions.

One of the major issues with WTHR is that the only source you can use for weather is your current location. It’s limiting, and doesn’t let you check the weather where you’ll be traveling soon, which is something every weather app should be able to do.

A little lighthearted for my taste.

A little lighthearted for my taste.

I couldn’t get a lot of diversity in conditions during my use of WTHR because where I live it’s been sunny for the past week. And in the next week, it will be the same with highs of 83º Fahrenheit, according to the app’s sources. Strangely, it displayed high temperatures as being 83º five out of seven days in the forecast with the other two being 82º. This, combined with the fact that every icon in the next seven days was sunny, seemed a bit suspicious.

I didn’t want to simply assume that the app was giving me the wrong information, so I headed over to Wunderground since it’s the most reliable provider I’ve used. Unfortunately, it showed that the last two days of the 7-day forecast would have thunderstorms, unlike WTHR’s report. The daily high temperatures were only a few degrees off, but the lows were as much as eight degrees different than that of Wunderground’s. Predicting the weather can be a bit tricky, but a source that differs this much from another seems a little questionable in my opinion.

Other than [possibly inaccurate] high and low temperatures, icons that show you what it’s like outside, text that reiterates what the icons told you, and a pleasant user interface, WTHR doesn’t have much to offer. The only toggle in the app is one to alternate between Fahrenheit and celsius. There is a little reload button if you need to fetch the latest data, but it’s unlikely that you’ll find something different from what’s currently on the screen. Nubilous, on the other hand, brings some extra features to the table and still manages to keep the minimal design.

The User Interface Lacks Contrast

“Simple” doesn’t quite describe WTHR. In fact, the only word that does is “minimal.” This app is a shade of white with little contrast. There’s no room for such things as a hint of dark grey remember, because the app is trying to be simple and too much contrast just doesn’t make it seem that way. I, for one, am not a fan of WTHR’s brutal simplicity. I’m one for contrast; not heavy, just more than what’s found in this app.

The problem with having such a lack of contrast is that you’re going to be squinting to see some of the information. This all depends on your surroundings of course, yet I found that even indoors, WTHR’s extremely minimal user interface was irritating. I wish it were more viewable without needing to adjust the brightness on my iPhone. I think the simple approach would be fine if the designer gave it some darker shades on the temperatures and clouds in the 7-day view.

Nubilous

When I first heard of this app, I wondered about the name. What is “nubilous,” after all? Since my Mac’s dictionary was reluctant to find its definition, I headed to the Web to discover that it means “cloudy or foggy.” That seems appropriate and it fits the app’s icon perfectly; the interface is a bit on the grim side as well, so one could infer fog.

There’s More Info to Glean

Unlike WTHR, Nubilous has a six-day forecast and offers more information than the average temperatures. Tapping a day will display the conditions for its morning, noon, evening and night. It’s nice to have this extra information, even if it’s just a little bit. I think that it’s the perfect amount of information to provide in a “simple” weather app.

A bit more customization.

A bit more customization.

As for accuracy, Nubilous reported no thunderstorms for the days that Wunderground did. It’s sad to see that both these apps aren’t even showing that there will be clouds in the sky on those days. I don’t know what service they use, but we have clouds in our skies a good two or three days a week in the summer.

Again, this app’s weather reports weren’t the most accurate. I found it to be two degrees off every day of the week. For most people, this isn’t a big deal and it probably doesn’t sway you away from the app, but I just wanted to point it out anyway. I’m not sure what Nubilous uses to collect weather data so I can’t really say how reliable things are, but a two-degree deficiency doesn’t seem to be too bad when compared to WTHR’s eight-degree problem.

User Interface

One of the things I really like about Nubilous is that it completely contrasts WTHR’s design. I wish the developer of WTHR would have realized that a dark theme could be nice for those who don’t like the light one. It’s nice to have options you know, but Nubilous doesn’t offer that either. I think it does fine without them anyway, though.

Humor and beauty: a great combination.

Humor and beauty: a great combination.

The smooth, modern blue and dark gray theme that Nubilous has adopted fits it well. I can see everything clearly without squinting and it doesn’t hurt my eyes as much. I also like the blue icon that shows the condition of current weather, in case you were too indolent to look out the window. The layout of the whole app is more like the iPhone’s stock Weather app and has a beautiful simplicity to it. I have nothing to complain about here.

Conclusion

Honestly, neither one of these simple clients is my dream app. Both of them have questionable weather reports and Nubilous is the only one with a fair taste in design. If I had to choose, WTHR would be out right away. It’s a great app and all, but I think it’s just too simple and needs some tweaks in its design. I’d like to see a dark theme in addition to the light one and vice versa in regards to Nubilous. With some little modifications here and there, they could both be capable apps.

Thanks to Our Weekly Sponsor: MyPrice

Our featured sponsor this week is MyPrice, an app designed to help freelancers determine how much to charge for projects, as well as calculate their hourly rates and so much more.

As a freelancer myself, I know what it’s like trying to figure out what a good rate is to charge and how much my time is worth per hour. And how the heck do I calculate what to charge a client for a specific job? These questions plagued me from the start, and I wish that MyPrice was out back then — it would’ve saved me a ton of headaches.

To come up with its figures, the app first starts with a very thorough list of questions ranging from your education level to your yearly automotive costs and everything in between. By entering the info as honestly as possible, the app takes the data and does its magic to come up with an hourly rate. And this doesn’t just work for writers, it’s also for illustrators, web developers and a ton of other popular freelancer professions.

But the real selling point for me is the ability to come up with quotes on projects. It can be so frustrating trying to come up with a number for a client when you’re not sure where to start. MyPrice takes your hourly rate, plus information about the project itself, and comes up with its own number on what the project is worth. And when you’re done, you can send the quote to Freshbooks — a popular piece of accounting software for freelancers — or email it to your client direct. That’s pretty sweet.

And we’re just scratching the surface here. There’s also tips and tricks, job listings and a ton more. This is a great tool to have in your freelancer arsenal.

Go Get It!

MyPrice is the real deal, and an excellent tool for professional freelancers across the world. It’s available right now and for a limited time, it’s free! Seriously, if you do any kind of work on the side, you need to go download this app for your iPhone right now.

Think you’ve got a great app? Sign up for a Weekly Sponsorship slot just like this one.

Unzipping Files In iOS Using ZipArchive

In this tutorial, I am going to demonstrate how you can zip and unzip files from within your iOS applications. We will be using a third party library called ZipArchive to achieve this. While there are a couple solutions out there to zip and unzip files, I feel that the ZipArchive library was the fastest and easiest way to get up and running.

Why Would I want To Unzip Files?

That’s a great question. There are a number of reasons why you might want to support zipping and unzipping files inside of your applications. Here are just a few:

Apple’s 50 MB App Store Download Cap

Apple has imposed a 50MB download limit over 3G on applications downloaded to appease carriers and not hog all of their bandwidth. One way to circumvent this is to keep your binaries very small, and download the resources your application needs. The best way to package these resources is of course, a zip file. So the process (as you will see demoed below), is to open your app, check for resource updates, download the zip file, and unzip it. Now you can ship smaller applications, that fetch their resources dynamically.

Dynamic Updates To Content

I touched on this above. When your application needs updated assets, the common practice is to submit an update to the App Store. This could take up to a week for Apple to Review and publish. A faster approach is to zip your assets up and stick them on a server somewhere (even your Dropbox) and have your app download and unzip them. This way, whenever you want to make asset-based changes to your application, you won’t need to submit another copy of it to the store.

Downloading Zip Files From The Web

One huge downfall of Safari and the Mail app is, they are unable to open zipped files. It would be nice to offer some sort of support to view zipped archives on your device. Many of the “download” apps in the store support this, and you can too with some help from ZipArchive.

Setting Up Your Project

Head over to http://code.google.com/p/ziparchive/ and checkout a copy of ZipArchive. Or you can just type this into your terminal.

svn checkout http://ziparchive.googlecode.com/svn/trunk/ziparchive-read-only

Once you have cloned the repository, delete the MakeFile file from the minizip folder. We will let XCode build our files. Now, drag this minizip folder as well as the ZipArchive.h and ZipArchive.mm files into your project, making sure to check “Create groups for any added folders”. Also, be sure your target is checked.

Note: No ARC Support

If you are using an ARC enabled project, you will need to tell the compiler not to use ARC for ZipArchive. To do this, click on the project in the left hand column. Then click on your target in the middle column and select the “Build Phases” tab.

Expand the “Compile Sources” area, locate ZipArchive.mm and double click on it. In the box that pops up, type in -fno-objc-arc and click Done.

Linking libz

The last step is to link your project against libz.1.2.5.dylib. From the Build Phases screen you navigated to above, expand the Link Binary With Libraries section and click the “+” button to add a new library. Search the list for libz.1.2.5.dylib, select it and click Add.

Now, compile your project and it should succeed with no errors. One thing to note is ZipArchive might produce some warnings, they are not a big deal, but if you are a warning Nazi (you should be), dig into the code and see if you can solve them yourself.

Downloading And Unzipping Files

I will now show you how easy it is to download a zip file from the web, unzip its contents, and use them in your project. The method of which we will download the files is very basic and most likely wouldn’t be used in production without further error reporting and checking.

The sample project has a view that looks like this:

It’s basically a UIImageView and a UILabel. Inside of the view controller I have set up IBOutlets for these two items. Make sure and download the sample project to see the implementation details. We will be downloading a zip file from the web that contains an image and a text file which you can see displayed in the screenshot above. Once unzipped, the image will be set as the viewable image in our UIImageView and the textual contents of the .txt file will be displayed inside of the UILabel.

**1. Import the ZipArchive headers **

#import "ZipArchive.h"

2. Download the the zip file

    // 1 
    dispatch_queue_t queue = dispatch_get_global_queue(
                                                       DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
    dispatch_async(queue, ^{
        NSURL *url = [NSURL URLWithString:@"http://www.icodeblog.com/wp-content/uploads/2012/08/zipfile.zip"];
        NSError *error = nil;
        // 2
        NSData *data = [NSData dataWithContentsOfURL:url options:0 error:&error];
 
        if(!error)
        {        
            // 3
            NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
            NSString *path = [paths objectAtIndex:0];
            NSString *zipPath = [path stringByAppendingPathComponent:@"zipfile.zip"];
 
            [data writeToFile:zipPath options:0 error:&error];
 
            if(!error)
            {
                // TODO: Unzip
            }
            else
            {
                NSLog(@"Error saving file %@",error);
            }
        }
        else
        {
            NSLog(@"Error downloading zip file: %@", error);
        }
 
    });

This preliminary code downloads a zip file from iCodeBlog and saves it to the caches directory for the application.

  1. Creates a dispatch queue in which to run our code on with default priority.
  2. Quick and dirty way of fetching data from the web.
  3. Resolves the path to the caches directory and writes out the downloaded data to a local zip file

Now that you have it downloading the file to disk, it’s time to unzip that file and make use of it’s contents.

3. Unzipping the downloaded file

The last step here is to unzip the file you just downloaded. To be clear, it was save to the path /Library/Caches/zipfile.zip and once extracted, it’s contents will be inside of the Caches folder as well.

Replace the //TODO: Unzip in the code above, with the following code:

ZipArchive *za = [[ZipArchive alloc] init];
// 1
if ([za UnzipOpenFile: zipPath]) {      
    // 2      
    BOOL ret = [za UnzipFileTo: path overWrite: YES];
    if (NO == ret){} [za UnzipCloseFile];
 
    // 3
    NSString *imageFilePath = [path stringByAppendingPathComponent:@"photo.png"];
    NSString *textFilePath = [path stringByAppendingPathComponent:@"text.txt"];
    NSData *imageData = [NSData dataWithContentsOfFile:imageFilePath options:0 error:nil];
    UIImage *img = [UIImage imageWithData:imageData];
    NSString *textString = [NSString stringWithContentsOfFile:textFilePath 
        encoding:NSASCIIStringEncoding error:nil];
 
    // 4           
    dispatch_async(dispatch_get_main_queue(), ^{
        self.imageView.image = img;
        self.label.text = textString;
    });

Here is an explanation of what’s going on.

  1. Opens the file and unzips it in memory
  2. Writes the unzipped contents out to a given path (Caches folder)
  3. Makes use of the unzipped files
  4. Updates the UI (on the main thread of course) with the newly fetched data.

It really is that simple.

Zipping Files

Now you are going to see how to go the other way and zip up some files on disk. Again, this could be particularly handy when you want to allow your users to share groups of files via the web or email.

If you completed the steps above, your caches folder should have some files lying around that we can just zip up again and send off. We are going to zip up the two files you previously unzipped, stuff them into a new zip file, and write that out to the documents directory.

In my sample project, I have created a new button at the top that says “Zip Files” which links to an IBAction called zipFilesButtonPressed: when tapped. That is where I will be doing the zipping:

- (IBAction)zipFilesButtonPressed:(id)sender
{
    // 1
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *docspath = [paths objectAtIndex:0];
 
    // 2
    paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
    NSString *cachePath = [paths objectAtIndex:0];
 
    // 3
    NSString *zipFile = [docspath stringByAppendingPathComponent:@"newzipfile.zip"];       
 
    // 4
    ZipArchive *za = [[ZipArchive alloc] init];
    [za CreateZipFile2:zipFile];
 
    // 5
    NSString *imagePath = [cachePath stringByAppendingPathComponent:@"photo.png"];
    NSString *textPath = [cachePath stringByAppendingPathComponent:@"text.txt"];
 
    // 6
    [za addFileToZip:imagePath newname:@"NewPhotoName.png"];
    [za addFileToZip:textPath newname:@"NewTextName.txt"];
 
    // 7
    BOOL success = [za CloseZipFile2];    
    NSLog(@"Zipped file with result %d",success);
 
}

Here is what’s going on:

  1. Resolve the path to the documents directory. We will need this when determining the path to write out our new zip file.
  2. Resolve the path to the caches directory. This is used to fetch the files that will be zipped up.
  3. Determines the path the zip file we will be writing out.
  4. Instantiates the ZipArchive object and tells it to create a new “in-memory” zip file. Note, the file won’t be written out until you call the corresponding CloseZipFile2 method.
  5. Resolve the path to the files that will be zipped up.
  6. Add the files to the zip archive. You can add as many files as you would like here. You can even add directories (ie you could have added the entire caches directory if you wanted to).
  7. Write out the zip file and close it. Just to test, we log the result to ensure that the zipping was successful.

After running through the application, tapping on the “Zip Files” button, look inside of the Application’s Documents folder (located ~/Library/Application Support/iPhone Simulator/[iOS Version]/Applications/[Unique ID]/Documents]. It should contain a single zip file called newzipfile.zip. If you unzip it, you should see the two files that you stuffed in there extracted.

Conclusion

You have now seen how to zip and unzip files on iOS devices using the ZipArchive library. You can download the sample project at the bottom of this post. As always, if you have any questions or comments, feel free to write them in the comments of this post or write them to me on Twitter @brandontreb.

Happy iCoding!

Download The Sample Project

ThinkGeek offers retro Padintosh Case for iPad

Have an iPad 2 or third-generation iPad? Do you love retro Macs? If so, then you need to order the cool Padintosh Case for iPad (US$24.99).

While it’s the front of an original 1984 Mac pictured on the case, the Padintosh actually protects the back of your iPad. You can use a standard Apple Smart Cover to protect the screen on your iPad.

The Padintosh is just too cool, and the use of MacPaint to make the screen of the “Mac” even more authentic is perfect. I couldn’t help myself — I just ordered one.

ThinkGeek offers retro Padintosh Case for iPad originally appeared on TUAW – The Unofficial Apple Weblog on Mon, 13 Aug 2012 19:00:00 EST. Please see our terms for use of feeds.

Source | Permalink | Email this | Comments

Twitter acquires Clutch.io, service essentially getting open sourced

Clutch.io is a service that allows iOS and mobile developers to easily and quickly do app testing, which helps them track just how customers use their apps. The service has been helpful in the past for a number of app developers and their products, but Clutch has now flipped over to just one client: The company has been acquired by Twitter. Clutch says it will work on the same type of work at Twitter, aiming to grow the company on a worldwide scale.

As for developers using Clutch now, there’s both good and bad news. The bad news is that the service is getting shut down — it will be supported until November 1, and after that Clutch’s servers will no longer work. But the good news is that Clutch is basically open sourcing the whole thing. The company says it will release all of the necessary documentation and software for devs to continue to run the testing service on their own servers. And any currently running tests are designed to “fail gracefully” should Clutch’s servers go down, so there shouldn’t be any issues with end users at all.

All in all, it sounds like a good move for Clutch, and that developers who might be affected will at least have a way to deal with that. As for us Twitter users, I’m curious to see how this affects Twitter’s mobile experience going forward. Twitter’s one of my most-used services, so anything that makes it even better sounds good to me.

Twitter acquires Clutch.io, service essentially getting open sourced originally appeared on TUAW – The Unofficial Apple Weblog on Mon, 13 Aug 2012 18:00:00 EST. Please see our terms for use of feeds.

Source | Permalink | Email this | Comments

Dominion officially coming to the App Store this week

My favorite card game to play with friends right now is called Dominion. It’s a game that’s set off a “deck-building” craze in the board gaming world, in that you build up a deck to play with as the game goes on. It’s inspired quite a few games on the App Store already (including the excellent Ascension), and there has even been an officially-sanctioned fan version of the game previously released. But that fan version disappeared a while ago, and that’s because we’re finally getting a full, official version of Dominion to play on iOS later on this week.

Rio Grande has promised to make a full version of the game for a while, and as of this Thursday, we’ll have it. The game looks and sounds great: free play of the base game, and then in-app purchase access to the game’s expansions as they’re released. You’ll be able to play by yourself against bots, online with friends, or even in a new “adventure mode” that turns the game into a single-player title.

The new app is essentially a frontend for an HTML 5 version of the game being worked on by a company called Goko, but as long as it’s Dominion and it works, no worries, right? We’ll find out how faithful this version is when it comes out on Thursday.

[via Pocket Tactics]

Dominion officially coming to the App Store this week originally appeared on TUAW – The Unofficial Apple Weblog on Mon, 13 Aug 2012 17:30:00 EST. Please see our terms for use of feeds.

Source | Permalink | Email this | Comments