Categories
Uncategorized

What the iPhone 20 and Galaxy S 23 Might Look Like Together

First came What the iPhone 20 Might Look Like. Now, this:

Categories
Uncategorized

Objective-C’s New NSNumber, NSArray and NSDictionary Syntaxes Mean Less “Yak Shaving” for iOS and OS X Developers


Yak shaving is a term used to describe a seemingly pointless activity that you actually have to do in order to get a larger task done, or as Jeremy Brown put it:

You see, yak shaving is what you are doing when you’re doing some stupid, fiddly little task that bears no obvious relationship to what you’re supposed to be working on, but yet a chain of twelve causal relations links what you’re doing to the original meta-task.

The term “shaving a yak” was used in the 1950 film Sunset Boulevard, but it’s more likely that its use in programming comes from Ren and Stimpy:

Many programming languages, especially those that pre-date modern scripting languages, often call on the programmer to do some yak shaving, and Objective-C is no exception. With XCode 4.5 and its new Clang compiler, you get some nice bits of syntactic sugar that I’m certain will make you say “Finally!” and save you from a fair bit of yak shaving.

NSNumber Literals

If you’ve been coding in Objective-C even just a little bit, you’ve probably come across NSString, the non-mutable string type used when developing for OS X’s Foundation framework. If you have, it’s likely that you’ve seen assignments that look like this:

NSString *myString = @"Hello, world!";

The @ is a handy bit of shorthand that specifies to the compiler that Hello, world! is an NSString literal. Without this bit of syntactic sugar, we’d have to write the above line of code like so:

NSString *myString = [NSString stringWithCString:"Hello, world!"];

Until now, there’s been no such syntactic sugar for NSNumber, Foundation’s type for wrapping numerical values in an object. It’s handy for doing things like wrapping numbers so that you can store them in collection classes like NSArray and NSDictionary, which can only store objects.

Until the current version of Objective-C (which comes with XCode 4.5), here’s how you’d assign NSNumbers given some numeric literals:

NSNumber *meaningOfLife = [NSNumber numberWithInt:42];
NSNumber *ussReliantPrefixCode = [NSNumber numberWithUnsignedInt:16309];
NSNumber *floatPi = [NSNumber numberWithFloat:3.14159];
NSNumber *doublePi = [NSNumber numberWithFloat:3.14159265358979];
NSNumber *avogadrosNumber = [NSNumber numberWithDouble:6.02214129E+23];

That’s a lot of work just to simply box a simple number type into an object. Luckily for us, Objective-C now supports NSNumber literals. Just as with NSString literals, NSNumber literals are preceded with the @ sign.

The code below uses NSNumber literals and is equivalent of the code above, but requires less typing and is easier to read:

NSNumber *meaningOfLife = @42;
NSNumber *ussReliantPrefixCode = @16309U;
NSNumber *floatPi = @3.14159F;
NSNumber *doublePi = @3.14159265358979;
NSNumber *avogadrosNumber = @6.02214129E+23;

Array Literals, NSArray, and NSMutableArray

Initializing NSArray and Accessing Its Elements the Old Way

If you’re coming to Objective-C from languages like JavaScript, Python or Ruby, you’re used to doing array assignments using literals.

Suppose you wanted to create an array containing the first names of the members of the Stark family from Game of Thrones. Here’s how you’d do it in Python and Ruby (and in JavaScript, as well, although you’d probably want to place the var keyword before starkFamily):

starkFamily = [
    "Eddard",
    "Catelin",
    "Robb",
    "Sansa",
    "Arya",
    "Bran",
    "Rickon"
]

There used to be no such thing as an NSArray literal. Here’s how you’d create the array above using Objective-C and NSArray — using the arrayWithObjects: method, which expects a comma-delimited list of objects terminated with nil.

NSArray *starkFamily = [NSArray arrayWithObjects:
    @"Eddard",
    @"Catelin",
    @"Robb",
    @"Sansa",
    @"Arya",
    @"Bran",
    @"Rickon",
    nil
];

It’s not that much more typing, but you have to remember to mark the end of the list with nil.

What’s far more unwieldy is array access. In JavaScript, Python and Ruby, if you wanted to access the element of starkFamily whose index is 2, you’d do it this way:

starkFamily[2]

In earlier versions of Objective-C, here’s how you’d access that element:

[starkFamily objectAtIndex:2]

Wow, that’s clunky. Even with XCode’s autocomplete feature (the analogue of Visual Studio’s Intellisense), it’s still a lot of typing for something as simple as array element access.

Initializing NSArray and Accessing Its Elements the New Way

With the latest version of Objective-C, we have NSArray literals. Here’s how you’d initialize the starkFamily array using an NSArray literal:

NSArray *starkFamily = @[
    @"Eddard",
    @"Catelin",
    @"Robb",
    @"Sansa",
    @"Arya",
    @"Bran",
    @"Rickon"
];

NSArray literals look almost like JavaScript, Python and Ruby array literals. The big difference is NSArray literals begin with a @ character, just as NSString and NSNumber literals do.

As for accessing elements from NSArrays you can now do so using a more familiar notation:

starkFamily[2]

Finally! I much prefer myArray[index] over [myArray objectAtIndex:index].

Initializing NSMutableArrays Using Array Literals

NSArray is an immutable type; once initialized, you can’t reassign, add, or remove any of its elements. NSMutableArray, a subclass of NSArray, is mutable. Here’s how you initialize an NSMutableArray using an NSArray literal:

NSMutableArray *starkFamily = [@[
    @"Eddard",
    @"Catelin",
    @"Robb",
    @"Sansa",
    @"Arya",
    @"Bran",
    @"Rickon"
] mutableCopy];

In the code above, we create an NSArray using an array literal and invoke NSArray‘s mutableCopy: method on it. The result is an NSMutableArray containing the array literal’s values.

As with NSArray, you can now access elements of an NSMutableArray using standard array notation…

starkFamily[2]

…and, of course, since the array is mutable, you can do stuff like this:

starkFamily[2] = @"Tony";
[starkFamily removeObjectAtIndex:0];

Dictionary Literals, NSDictionary, and NSMutableDictionary

Initializing NSDictionary and Accessing Its Elements the Old Way

Different programming languages use different terms for what’s roughly the same thing: an object that stores values which you can look up using keys. JavaScript keeps it simple by using objects for this task, Ruby has hashes and Python has dictionaries.

Consider the following Python dictionary definition:

importantNumbers = { 
  "Meaning of life" : 42, 
  "USS Reliant prefix code" : 16309, 
  "Single-precision pi" : 3.14159, 
  "Double-precision pi" : 3.14159265358979, 
  "Avogadro's Number" : 6.0221415E+23
}

Ruby’s hash syntax is similar:

importantNumbers = { 
    "Meaning of life" => 42,
    "USS Reliant prefix code" => 16309,
    "Single-precision pi" => 3.14159,
    "Double-precision pi" => 3.14159265358979,
    "Avogadro's Number" => 6.0221415E+23
}

If you wanted to access the number associated with the key Meaning of life in either Ruby or Python, you’d do it this way:

importantNumbers["Meaning of life"]

In Objective-C, the equivalent structure is the NSDictionary class. Here’s the old-school Objective-C equivalent to the code above. Since NSDictionary stores only objects, we have to wrap the numbers in NSNumbers using the new literal syntax:

NSDictionary *importantNumbers = [NSDictionary dictionaryWithObjectsAndKeys:
    @42, @"Meaning of life",
    @16309U, @"USS Reliant prefix code",
    @3.14159F, @"Single-precision pi",
    @3.14159265358979, @"Double-precision pi",
    @6.0221415E+23, @"Avogadro's Number",
    nil];

Note that the list have to provide the dictionaryWithObjectsAndKeys: method lists the value first and the key second, which is the reverse of how most other programming languages do it. As with NSArray‘s arrayWithObjects: method, we have to mark the end of the list with nil.

If you thought the code above was a bit much, imagine what it would look like without NSNumber literals!

As for accessing values in the dictionary, here’s the old way of doing it:

[importantNumbers objectForKey:@"Meaning of life"]

That’s a lot of typing just to get to a value.

Initializing NSDictionary and Accessing Its Elements the New Way

Luckily, the Objective-C that you get with XCode 4.5 gives us dictionary literals. Here’s how you define importantNumbers now:

NSDictionary *importantNumbers = @{
    @"Meaning of life" : @42,
    @"USS Reliant prefix code" : @16309U,
    @"Single-precision pi" : @3.14159F,
    @"Double-precision pi" : @3.14159265358979,
    @"Avogadro's Number" : @6.0221415E+23
};

That’s much better. Languages like JavaScript, Python and Ruby have standardized curly braces ({ and }) for specifying dictionary-style collections, and it’s nice to see this syntax in Objective-C. The order is also what we expect: key first, value second. And finally, no need to use nil to terminate the list.

The syntax for accessing a value from an NSDictionary is also much simpler:

importantNumbers[@"Meaning of life"]

Much better.

Initializing NSMutableDictionary Using Dictionary Literals

Like NSArray, NSDictionary isn’t mutable, but it has a mutable subclass with a similar name. It’s NSMutableDictionary, and like NSArray, you can use a literal and the mutableCopy: method to create one:

NSMutableDictionary *importantNumbers = [@{
    @"Meaning of life" : @42,
    @"USS Reliant prefix code" : @16309U,
    @"Single-precision pi" : @3.14159F,
    @"Double-precision pi" : @3.14159265358979,
    @"Avogadro's Number" : @6.0221415E+23
} mutableCopy];

As with NSDictionary, you can access elements of an NSMutableDictionary using the new syntax:

importantNumbers[@"Meaning of life"]

And since it’s mutable, you can make changes:

importantNumbers[@"Meaning of life"] = @43;
[importantNumbers setObject:@2012 forKey:@"iOS 6 launch year"];

Available Now, and Not Just for iOS 6

The latest version of XCode, 4.5, includes the latest Clang compiler, which supports these new syntaxes. Since they’re syntactic sugar and not part of any additions or revisions to the Foundation framework, you can use them in any iOS project.

Better still, if you’ve got old projects that you’d like to update to use these new syntaxes but dread having to do so manually, XCode 4.5 has a feature you’ll like. Under the Edit menu, you can select Refactor, and inside that submenu is the Convert to Modern Objective-C… command.

Categories
Uncategorized

Meanwhile, in Japan…

Ginza District, Tokyo, Japan: I’m not sure if the guy on the right is waiting for an iPhone 5 or a katamari.

Categories
Uncategorized

The London Underground’s Advisory for iOS 6 Users

Ouch.

Categories
Uncategorized

Mobile Developer News Roundup: The Amazing iOS 6 Maps, iPhone 5 Lines, Why You Should be an iOS Developer and the iOS 6 Feast

The Amazing iOS 6 Maps

The Amazing iOS 6 Maps is a Tumblr devoted to showcasing the shortcomings of the new Maps application in iOS 6.

I’ve also enjoyed this twist on the “Condescending Wonka” meme:

iPhone 5 Lines and Samsung’s Response

Here’s a photo of an iPhone 5 line in Australia posted by @iFixit at 3:55 p.m. EDT:

Here’s the same line an hour later, with the sun having risen:

There are similar lines in the other eight countries where the iPhone 5 will be available at Apple Stores on Friday.

Anticipating this sort of response (and probably stinging from being called out as copycats and getting a one billion dollar speeding ticket for doing so), Samsung have put out this rather funny ad mocking the sort of Apple fan who lines up for the latest iDevice:

Matt Campbell on iOS Development

Matt Campbell, author of the excellent book Objective-C Recipes and the Mobile App Mastery site, mailed out this advice to subscribers to the Mobile App Mastery mailing list:

I’ve been getting all kinds of questions about being an indy app publisher and mobile apps in general. Let’s see if I can answer some of these now.

Do I Need To Quit My Job?

Not at all. Once you are comfortable with iOS development you can build an app in your spare time. Mobile app development with iOS particularly is probably much less complicated that what your are used to. This actually makes it ideal as a side project.

In fact, I had two apps developed and going strong before I quit my job. The nice thing about iOS as a side gig are that it’s like giving yourself a bonus whenever you want while keeping your secure paycheck.

It’s really up to you when it comes to this. I quit because I was determined to start my own business (with or without mobile apps).

Is iOS, Windows or Android The Best?

These are all great mobile platforms and there are more – you can even make mobile web apps. I recommend iOS for a few reasons:

iOS is the easiest system because it is closed. You don’t need to worry about the hardware and you can focus on the code. You must use things from Apple’s vertical stack and this makes it very easy to use.

Apple has the best customers. Almost everyone I know who developers for multiple platforms agree that the Apple app store customers are the best.

Apple is vertically integrated. It’s frankly a no-brainer to port your iPhone app to the iPad and Mac appstores potentially tripling your revenue. They all use the same programming language and iPad and Mac are as easy as iPhone to develop for.

How Hard Is It To Learn iOS, Really?

I won’t lie – learning iOS development at first is daunting even for experienced programmers. It’s because the patterns are so different than what most of us were used to. I went at it alone and it took me a good three months to get started. Of course you can cut down on that time these days and I’ve been able to get developers up to speed in a matter of days with iPhone Boot Camp.

All that being said – once you learn iOS it becomes almost absurdly easy to develop and publish apps. One day you will “just get it” and after that it really does become second nature. Most developers who work with iOS fall in love with the system (me included).

Ray Wenderlich’s iOS 6 Feast

Ray Wenderlich’s site on iOS development — you should have it bookmarked if you’re even thinking about writing iOS apps — has announced the iOS 6 Feast, a smorgasbord of information and tutorials for developers looking to dive into the latest version of iOS. Check it out — you don’t want to miss it!

Categories
Uncategorized

The “Bottom Line” from Many iPhone 5 Reviews, All in One Place

CNET: Finally, the iPhone We’ve Always Wanted

I can say that, if you choose iOS, this is the phone to get. It’ll feel like part of a unified family: the iPhone 4, 4S, and 5 are one continuous swoop of design, a three-step path that feels for once like a complete line rather than an archaeological timeline of iPhone Evolution. The near future of phones may involve new wireless technologies and plenty of exciting companion peripherals, but the shape of the phone itself feels ready to settle in for a spell, like laptops. That’s what happens when you find a successful solution to a problem. The iPhone 5 is approaching perfection of a form, not a solution to a problem that isn’t there.

If you own an iPhone 4, upgrade to the iPhone 5. Even if you own an iPhone 4S, give it a long look and decide if you’d like 4G LTE, or if you even have LTE service in your area.

Living with the iPhone 5 for a week, I forgot about its large screen. I forgot how thin it was. I forgot about the camera improvements. Sometimes, I even forgot about 4G LTE, and got confused whether I was currently surfing on Wi-Fi or not. The iPhone settles in, feels natural, doesn’t impose. Going back to my iPhone 4S, it feels thicker, heavier, small-screened, but no less impressively designed. Somehow, the iPhone 5 and iPhone 4S feel like they can co-exist.

If you’re looking for a show-off gadget, something with gee-whiz bells and whistles, then go somewhere else…except for the fact that people will inevitably want to see the iPhone 5 and grab it out of your hand. But, if you’re looking for an excellent, well-conceived phone…well, here it is.

AllThingsD: The iPhone Takes to the Big Screen

If you own an iPhone 4S and especially if your carrier won’t let you upgrade yet at the $199 price, you may be content with just upgrading to the new software, which gives you a lot. But you’ll be stuck with the smaller screen, bulkier size and pokier cellular speed. If you own an older model iPhone, or are switching from another phone, however, the iPhone 5 is an excellent choice.

Apple has taken an already great product and made it better, overall. Consumers who prefer huge screens or certain marginal features have plenty of other choices, but the iPhone 5 is an excellent choice.

The Loop’s iPhone 5 Review

My experience with the iPhone 5, iOS and the EarPods has been great. The iPhone is everything Apple said it would be and with iOS 6 built-in, it’s clear to me that Apple has another winner on its hands.

I can’t think of any good reason why anyone wouldn’t upgrade or purchase the iPhone 5.

New York Times: The iPhone 5 Scores Well, with a Quibble

Should you get the new iPhone, when the best Windows Phone and Android phones offer similarly impressive speed, beauty and features?

The iPhone 5 does nothing to change the pros and cons in that discussion. Windows Phones offer brilliant design, but lag badly in apps and accessories.

Android phones shine in choice: you can get a huge screen, for example, a memory-card slot or N.F.C. chips (near-field communication — you can exchange files with other N.F.C. phones, or buy things in certain stores, with a tap). But Android is, on the whole, buggier, more chaotic and more fragmented — you can’t always upgrade your phone’s software when there’s a new version.

IPhones don’t offer as much choice or customization. But they’re more polished and consistently designed, with a heavily regulated but better stocked app catalog. They offer Siri voice control and the best music/movie/TV store, and the phone’s size and weight have boiled away to almost nothing.

If you have an iPhone 4S, getting an iPhone 5 would mean breaking your two-year carrier contract and paying a painful penalty; maybe not worth it for the 5’s collection of nips and tucks. But if you’ve had the discipline to sit out a couple of iPhone generations — wow, are you in for a treat.

Engadget’s iPhone 5 Review

The iPhone 5 is a significant improvement over the iPhone 4S in nearly every regard, and in those areas that didn’t see an upgrade over its predecessor — camera, storage capacity — one could make a strong case that the iPhone 4S was already ahead of the curve. Every area, that is, except for the OS. If anything, it’s the operating system here that’s beginning to feel a bit dated and beginning to show its age.

Still, the iPhone 5 absolutely shines. Pick your benchmark and you’ll find Apple’s thin new weapon sitting at or near the top. Will it convince you to give up your Android or Windows Phone ways and join the iOS side? Maybe, maybe not. Will it wow you? Hold it in your hand — you might be surprised. For the iOS faithful this is a no-brainer upgrade. This is without a doubt the best iPhone yet. This is a hallmark of design. This is the one you’ve been waiting for.

T3’s iPhone 5 Review

So, what to make of this latest upgrade. There’s no denying that the iPhone 5 is a lovely thing, and the best iPhone to date. It could well be Apple’s best-selling unit ever.

But a lot has changed in a year, and the current crop of Android superphones – and the incoming Windows Phone 8 handsets – have closed the gap. For nearly every “new” feature announced at the Keynote, there was a Samsung, Android, Windows, Nokia, Sony or HTC fan saying “my phone already does that.”

Apple’s competitors  never been closer in terms of quality, function and aesthetics and from your feedback on our social networks we know how many of you are jumping ship to phones with a bigger screen and more features.

Given that iPhone 4S users can upgrade to iOS 6 and do just about everything the iPhone 5 can do, and that Android users can get similarly impressive handsets for less dosh, we reckon the smart money won’t all be going on a new iPhone this year, even if the mass market can’t get enough of it. It’s good, very good. But it’s no longer the best around.

Pocket Lint’s iPhone 5 Review

What Apple has created with the iPhone 5 is an extremely polished smartphone that oozes appeal. It’s incredibly well built, easy to use, features a beautiful screen, and comes packed with enough speed and power to service all your requirements. The hardware is just stunning. It really is impressive how much is crammed into such a tiny box.

On the software front the story isn’t as cut and dry. Apple’s iOS operating system is clean and easy to use, but iOS 6 adds little to the story over iOS 5. It doesn’t feel like it has taken the same leap forward as the hardware, and that this version of the OS has been more about filling gaps or replacing services rather than re-writing what’s available from the ground up. There are some nice touches, but they are just that.

Change isn’t always necessary, nor needed, but if there were things you didn’t like in iOS 5, chances are they will still be here in iOS 6. Microsoft’s Windows phone trounces iOS 6 on the social connected stakes even though Apple has added Facebook this time around. BlackBerry’s BB10 OS, due out in February 2013, beats it on the email and messaging integration (we’ve played with the OS already), and Android is perfect for those that want customisation and control beyond choosing wallpapers.

That’s not to say it is a poor experience, far from it. The chances are you will be more than happy with the performance of the phone and what it offers on the software stakes. The iPhone is still the smartphone we would recommend when it comes to apps. Whilst Android is getting closer to enjoying a parallel launch schedule for apps, Windows Phone and BlackBerry are light years behind the ingenuity shown on a daily basis either from Apple or third-party developers.

While the hardware and design here is cutting edge, the software plays it safer than we would like. For those of you that have already left the Apple eco-system for Samsung or HTC, for example, the iPhone 5 isn’t likely to draw you back. You might marvel at the build and design, but Apple with the iPhone 5 has created a smartphone that is too safe for you: you’ll feel too mollycoddled.

Instead Apple has created a phone that the millions of current iPhone users will want to upgrade to. iPhone owners will love it, enjoy all those new features, and appreciate all the hard work, design, and engineering that has gone into it.

The iPhone 5 is a phone that makes you feel safe. A phone that you know exactly how to use as soon as you take it out of the box and that is perfect for a huge number of people.

It’s a phone that, until you start craving the iPhone 6, will serve you very well indeed.

TechCrunch: With iPhone 5, Apple Has Chiseled the Smartphone to Near Perfection

If you’ve been debating getting the iPhone 5 — and it seems like many of you haven’t debated it too much, with 2 million pre-orders — I suggest you make the jump. Even from the iPhone 4S, the iPhone 5 is a big, noticeable improvement. (Though of course I understand that carrier contract commitments may come into play there as well.) If you have an iPhone 4 or, heaven forbid, an iPhone 3GS, get the iPhone 5 as soon as you can.

If you have an Android phone and have been waiting for a big iPhone update to explore or re-explore the device, now is the time. And you Windows Phone 7 users who are getting screwed in the move to Windows Phone 8, you may want to look as well. And if you’re still a Blackberry user, well, good luck with that. I think you’re beyond my help.

Those worried about the talk of “disappointment” surrounding the iPhone 5, I suggest you simply go to an Apple Store starting on Friday and try it for yourself. My guess is you’ll immediately recognize just how ridiculous all that bluster actually is. The iPhone 5 is the culmination of Apple doing what Apple does best. This is the smartphone nearly perfected.

CBC News: iPhone 5 Not Terribly Innovative, But Still a Smart Package

Given the iPhone 5’s sales expectations, it’s clear that many consumers just don’t care about the pricing. It’s simply a must-have gadget.

Other manufacturers’ phones have newer, more innovative technologies in them – wireless charging or near-field communications that allow for data sharing by tapping phones together – but few if any inspire the obsessive devotion that Apple does.

Few have also been able to bundle everything together – music and video content, hardware, software and apps – into a simple and elegant total package. The iPhone 5 may not be terribly innovative, but it does deliver that package better than any previous Apple product, and better than just about any other smartphone.

USA Today: Apple iPhone 5 in Front of the Smartphone Pack

People have always had lofty expectations for the iPhone 5, especially as the competition stiffens. In delivering a fast, attractive, LTE-capable and larger-screen handset, Apple has met those expectations with a gem.

Daring Fireball’s iPhone 5 Review

The question everyone who hasn’t yet pre-ordered wants answered: Should you upgrade? My answer is simple. If you can afford it, yes.

There’s a reason why, just as with all five of its predecessors, it just says “iPhone” on the back. The iPhone 5 is all new technically, but it’s the exact same thing as an idea. Apple is simply improving upon that idea year after year in infinitely finer detail, like a fractal. It’s nice.

Categories
Uncategorized

Microsoft Signs Licensing Deal with RIM, But You Wouldn’t Know It From RIM’s Site

Back when I worked at Microsoft Canada, we’d often pay visits to the nearby city of Waterloo, home of the world-famous University of Waterloo and its killer computer science and engineering programs and RIM. We’d occasionally meet up with some of the RIM folks, either formally or casually, and at some point, one of the RIMmers would say “Someday, we shall be one”. This shouldn’t be news to anyone who hangs out in Waterloo; the “Microsoft should buy RIM” idea has been floating around since before the iPhone crashed the party and left with all the cool kids.

When the headline Microsoft Signs Licensing Agreement with Research in Motion appeared earlier today, some tech writers had to make it very clear that this licensing deal “isn’t what you think”. It’s a licensing agreement for the exFAT file system, the successor to FAT, whose 32-bit file allocation table (from which the FAT acronym comes) limits filesizes to 4GB. exFAT-formatted storage will appear in “some BlackBerry models”. If you bounce files back and forth between Macs and Windows boxes on external drives or naked drives and “toasters”, exFAT’s a great way to format them, as the modern versions of those OSs read exFAT “right out of the box”. exFAT was designed with Flash drive technology in mind, requiring less processor power and memory.

The fact that this deal appears in an article in Microsoft’s News Center but doesn’t appear at all on RIM’s Newsroom page is very telling. For Microsoft, it’s a win: another licensee and more income, and someone’s going to get a nice bonus at the end of the fiscal year. For RIM, it’s a nice tech tweak, but certainly nowhere as splashy as the other mobile vendors’ recent announcements, and nothing to soothe some presumably agitated investors.