Posts Tagged ‘iphone’

  • URL Encoding an NSString on iOS

    I’ve been working on an iPhone app for the last few weeks, which I’ve really enjoyed. Every now and again, though, you hit what seems like a bug in the iOS SDK. This seems to happen much more frequently than it ever did when I was coding in C#. As a result, my default debugging approach – that any problem with my app must be my fault rather than something in the framework – has shifted slightly. I’m now much more likely to question the framework itself, and with a quick Google search it’s common to find other developers who have experienced the same problem.

    Here’s one that bit me recently. NSString has a method called stringByAddingPercentEscapesUsingEncoding, which purports to make the string safe for use, say, as a parameter to a URL. There are several characters that are reserved in parameters to URLs – for example the slash character, or the ampersand, because these are characters that are used to delimit the URL itself. Therefore we encode these, and this is done using the percent encoding scheme.

    As an example, if you want to use the string hell & brimstone + earthly/delight (and why wouldn’t you?) as a parameter to a URL then you’ll need to convert it to hell+%26+brimstone+%2B+earthly%2Fdelight so that the ampersand becomes %26, the plus becomes %2B and the slash becomes %2F. Note that spaces are encoded as pluses, which is why the original plus sign needs to be encoded.

    But stringByAddingPercentEscapesUsingEncoding doesn’t respect these rules, and actually produces this: hell%20&%20brimstone%20+%20earthly/delight

    It fails to encode the ampersand, the slash and the plus, and many (most?) web servers will be confused by that. It encodes the spaces as %20, which is just as acceptable as encoding them as a plus.

    In short, it’s completely broken, which is frustrating. But thankfully there’s a lower-level API we can use which, thanks to the magic of Objective-C categories, we can tack on to NSString. This is based on a blogpost by Simon Woodside, which I’ve just turned into a category.

    Here’s the category’s header file:

    #import <Foundation/Foundation.h>
    
    @interface NSString (URLEncoding)
    -(NSString *)urlEncodeUsingEncoding:(NSStringEncoding)encoding;
    @end
    

    And here’s the implementation:

    #import "NSString+URLEncoding.h"
    
    @implementation NSString (URLEncoding)
    
    -(NSString *)urlEncodeUsingEncoding:(NSStringEncoding)encoding {
    
    	return (NSString *)CFURLCreateStringByAddingPercentEscapes(NULL,
    			   (CFStringRef)self,
    			   NULL,
    			   (CFStringRef)@"!*'\"();:@&=+$,/?%#[]% ",
    			   CFStringConvertNSStringEncodingToEncoding(encoding));
    }
    
    @end

    And now we can simply do this:

    NSString *raw = @"hell & brimstone + earthly/delight";
    NSString *url = [NSString stringWithFormat:@"http://example.com/example?param=%@",
    			[raw urlEncodeUsingEncoding:NSUTF8Encoding]];
    NSLog(url);

    And the result will be exactly as we hoped:

    http://example.com/example?param=hell%20%26%20brimstone%20%2B%20earthly%2Fdelight

  • Made by Many Talk: John-Henry Barac on the Guardian iPhone App

    We’ve held some interesting talks here at Made by Many over the last couple of years, and I’m thrilled to announce that we’ve got an exciting one coming up next week.

    We’ve invited John-Henry Barac, the designer of the tremendously successful Guardian iPhone app, to come and share his experiences in designing a newspaper app for the iPhone. Our friends at BBH London have kindly agreed to provide a room for the talk, for which we’re very grateful.

    The Guardian iPhone app has been a huge hit, and recently won the innovation award at the AOP awards, where the judges said that it “broke the mould of how content to mobile can be monetised”.

    The Guardian have long had a reputation for small innovative projects that help to point the way towards a future for quality online journalism, and the iPhone app is an excellent example of that approach. While other newspapers circle the wagons, the Guardian is committed to quality journalism that plays a full part in what Steve Jobs calls ‘the open web’, but have still scored a hit with a paid-for application.

    What specific issues were there in developing the Guardian app? Can print publications simply transition to tablets and phones by preserving the page metaphor, or do they need to re-imagine what they do at a more fundamental level? Should they follow Apple’s lead and adopt skeuomorphic interfaces, or should they turn their back on the paper-based past entirely? How can newspapers and magazines develop new services on this new class of mobile device?

    These are just a few of the issues that John-Henry will offer an opinion on, and he’s ideally placed to do so. He spent a decade at the Guardian on the print side as an art director, and is therefore both an insider and an outsider; a print man helping to forge a digital future. His is a fascinating perspective on this most hotly debated areas of digital culture.

    The talk will start at 1pm on July 15th at BBH London’s offices at 60, Kingly Street, London, W1B 5DS and will last for between 45 minutes and an hour, depending on the number of questions.

    We’d love you to come to hear what John-Henry has to say, and to put your own questions to him in person. If you’d like to attend the talk, please email me at james@madebymany.co.uk. There are – obviously – limited spaces available, so it’s best to book your place early.

  • Wanted: An Exceptional Objective-C Developer

    We have a very small and talented development team here at Made by Many. We’re technology agnostic, and while we have a very strong Ruby backbone, we regularly supplement our in-house skills with specialists from a range of disciplines. Most often we do this with a trusted network of specialists. But now we are ready to add an exceptional Objective-C developer to our team.

    The primary focus for this new role will be – of course – the iPhone and iPad (not forgetting the iPod Touch).

    Why would you want to join Made by Many? We’re not like other companies. We are relentlessly focused on user experience through a synthesis of great design and great technology. We have a great client list, and we’re adding to it so fast that we can’t keep the clients page on our website up to date.

    We work in a highly collaborative and open way, and individuals can make a big impact here. We don’t have departments or organisation charts. We work in small project teams, using Agile methodologies, in close contact with our clients. Technologists are integral to what we do, and without exception are involved from the inception of every project and at every stage thereafter. We all have strong opinions yet we are all open-minded. There’s a wealth of experience in our team, yet a hunger for new ideas. We believe that technology is a powerful force for good, and we love experimenting with new stuff.

    Almost everything about the role is up for discussion, and the specifics will largely be down to the right candidate emerging. Naturally, we will offer a competitive salary and a good range of benefits. Not just the normal ones, either, although we offer those too. For example, this year almost all of us went to SXSWi, with the company picking up the large majority of the tab.

    Obviously, you will need to be a very talented developer with a deep knowledge of the iPhone SDK, and a proven track record in Objective-C development. We will also expect you to have a solid understanding of fundamental web technologies, and the fundamental tools of software engineering. Everyone at Made by Many talks to clients, and you’ll need to be comfortable with attending and contributing to client meetings. We’re not looking for code monkeys who shrink from human contact.

    We’re really excited about this opportunity, and we can’t wait to hear from candidates. Please send a copy of your CV and a brief covering email to james@madebymany.co.uk along with any questions or comments. Absolutely no agents, please.

  • A review of iMapMyRide for the iPhone

    On the recommendation of fellow cyclist Brian Sheridan who I met at SXSW (the conference that keeps on giving) I downloaded the iMapMyRide iPhone app last weekend to track my latest jaunt out on the bike.

    I’ve been a cyclist for about 20 years and have used many different handlebar mounted computers over that time. These show all the predictable stuff like trip distance, average speed, current speed, overall distance, pedal cadence and a few other things. All measured by magnets on the wheels and sensors attached to the frame. I’ve even used heart rate monitors when I was really serious (and fit).

    But this iMapMyRide app takes geekyness + sport to a new level.

    Read full post

  • iPhone OS 4.0: Now With Added Evil

    Hidden among the details of Apple’s announcement of the next version of the iPhone operating system last week was a nasty, snide little addition to the terms and conditions that iPhone app developers must agree to in order to get their apps into the App Store.

    In effect, it says that you must use Apple’s developer tools and preferred programming language to develop iPhone apps. Which, on the face of it, is uncontroversial. It’s Apple’s platform, so you use Apple tools and languages. The problem is that there are significant efforts from other companies and projects to make it easier to transition to iPhone app development from other platforms, such as Microsoft’s .NET and Adobe’s Flash, as well as to make it easier to write apps that run on multiple mobile platforms. Apple’s devotees have had problems with these alternative platforms before, as I wrote a few months ago, but now Apple have taken the extraordinary step of embedding their own language preference in the terms and conditions of even being an iPhone developer at all.

    The new rule expands section 3.3.1 of the developer agreement to state that “applications must be originally written in Objective-C, C, C++, or JavaScript as executed by the iPhone OS WebKit engine”. Objective-C is the language that most developers use to write applications for Mac OS X, and it’s by far the most popular language for iPhone apps, too. C and C++ are probably the most popular languages for writing games, a key part of the App Store’s success.

    Apple have had problems applying their guidelines consistently in the past, and that’s partly because the wording of the developer agreement is fairly loose. The new additions are no exception.

    Read full post

  • iPhone Abroad: Usability Nightmare

    Last month almost the entire company decamped to Austin for the South by Southwest (SXSW) interactive festival. My experience with my iPhone there was frustrating, to say the least.

    My carrier, O2, prices a 3G data connection when abroad so rapaciously (at £6 per megabyte), that there’s no realistic option of having a network connection when abroad, unless you can find a functioning wifi network. Open wifi networks appear to more common in Austin than they are in London, especially in hip cafés and bars (not that I ever visit such places in London), but at times when you are genuinely out and about, you’re stuck with no data at all, and the iPhone in effect becomes an iPod Touch.

    To be fair to O2, something that does not come naturally to someone who’s been consistently underwhelmed by them for years such as myself, they do send you a text message as soon as you emerge from your airplane mode, warning you about what a rip off their data roaming charges are. At those rates I’d have more respect for them if they walked up to me with their finger making a pretend gun in their coat pocket and asking for my dinner money.

    Read full post

  • Apple Needs a Good Syncing Story Quickly (Or: How We Need that Syncing Feeling)

    Now that the dust has settled from the latest application of the Reality Distortion Field and we are all salivating at the chance to get our hands on the iPad, it’s time to think about how all of these devices will work in our day to day lives.

    I’m a fully paid up member of the Apple devices fanboy club. I carry an iPhone and a 5th generation iPod with me wherever I go (even the largest capacity iPhone is nowhere near enough to store even a third of my music collection), I have a MacBook Air for holidays and overseas trips, a 17″ MacBook Pro for work and a huge cheese grater Mac Pro at home for media storage and its raw computing horsepower.

    I love all of these devices for different reasons, but one thing I don’t love is the difficulty of keeping them all up to date with the latest versions of my data.

    Read full post

  • What if Apple became a bank?

    RRW have been trading on a rumour that Apple’s new iPhone is going to have NFC functionality in the coming Spring. About bloody time if you ask me. NFC (Near-Field Communication) will technically allow you to use your phone as not only an Oyster card, a passport or a debit card but will also allow you to read RFID chips so you can see how much is on your Oyster card, check the microchip of a lost pet against the Pet ID database or even take payment from other people. There’s a wealth of possibilities. Nokia already has devices on the market with NFC built in but has never managed to make it appeal to the public.

    Apply being Apple, there’s no doubt that if they were indeed to implement NFC (clearly they’d call it something completely different) they would have some business model built around it in order to maximise profit from the new feature. And banking, micropayment and payments in general could do with a real shake up at the moment.

    apple bank

    It might sound ridiculous, it might sound scary or far fetched, but I don’t see why not. If you were to tell me 10 years ago that Apple were going to be the number one music retailer in the US, I’d have laughed in your face and insulted your intelligence. Probably.

  • iPhone Developers and Language Snobbery

    [Update: Jeff LaMarche (author of one of the best iPhone books on the market) wrote one of his trademark 'no tact' responses to this post. I'd be very interested to know what people think about his post.]

    [Update 2: Guy English (aka kickingbear) chimes in on this debate with what is the best response I've seen from a hardcore Cocoa developer. Basically: Apple's tools are probably better at producing better iPhone apps, but let's see what MonoTouch and Flash can deliver before we definitively say that they are no good.]

    Novell recently announced a product called MonoTouch, which allows developers to write iPhone applications using C#, a language invented by Microsoft (but since standardised). It’s a very clever piece of work that allows someone without experience of Objective-C – the only option that Apple gives you for iPhone development – to write an iPhone application with a reduced learning curve.

    Yesterday, Adobe followed suit and announced that they are working on a way to make native iPhone applications with their Flash technology.

    Naturally, this is a good thing. Talented C# and Flash developers will be able to write excellent iPhone apps and we can all go home happy. The fact that two heavyweights in the technical space have made these tools is a massive compliment to Apple’s achievement with the iPhone.

    Not if you listen to many Objective-C programmers it isn’t.

    Read full post

  • I’ve had a baby. What have you all been up to?

    (or 10 things that have changed on the web since November '08)

    In the time I’ve been away and had a baby (she’s 10 months old this week…), a lot has happened.

    My baby

    The internet being a many-splendoured and rapidly changing thing, I hesitate to attempt any coherent summary of all that’s gone on.

    Instead, I’ll just pick out a few things that have sprung up on my radar as significant changes between November ‘08 and September ‘09. Broadly speaking, I see them as these:

    1. digital as support act > digital as headliner
    2. semantic web frenzy > real-time web frenzy
    3. slow fade of shiny 2.0 aesthetic > upsurge of big type mobile-friendly aesthetic
    4. Twitter as geekorama > Twitter as mainstream
    5. Google primacy > Google supremacy
    6. 43 white, analogue US presidents > 1 black, digital US president
    7. banner ads and buttons > social, shared content
    8. state control of ISPs (Iran, China) > online social mobilisation and subversion
    9. stream of rubbish reality TV on iPlayer and 4OD > demise of Keith Floyd
    10. Plus, of course the launch of Spotify, Facebook Connect, a proliferation of Twitter clients and more iPhone apps than you can shake an accelerometer-enabled stick at.

    You’re more than welcome to plug the gaps on the things I’ve missed whilst I was lost in the apparently endless cycle of feeding, sleeplessness, nappy-changing and washing.

    Please, tell me: what other important stuff have I missed?

    P.S. As I was writing this, I found a couple of Trend Blend maps via Ross Dawson’s blog which suggest that between 2008 and 2009, life has gone from being an ordered train journey through society, politics, technology et al…

    Trend Blend map 2008

    Trend Blend map 2008

    …to a more scary-looking hydra, beset by ominous little red demons. Perhaps I should have stayed at home, offline, with the curtains closed.

    Trend Blend map 2009

    Trend Blend map 2009

Our latest tweets

Categories

Archives

Find us on the web