iOS Workshop

After extensive delays and procrastination I am finally getting back to blogging and writing this post.

This is really just a chance for me to look over the material again and write some notes and thoughts on what was covered for anyone who wants to read it, it’s not intended to be any sort of tutorial.

During the workshop we covered the three skill sets needed to develop iOS apps, the Xcode development environment, the Objective-C language that Apple uses, and the Cocoa Touch SDK frameworks.

Unfortunately we used Xcode 3 and not the most recent Xcode 4, which consolidates the code development and interface builder into one program, instead of two separate ones. It seemed a perfectly respectable IDE, it managed project files, it autocompleted variable names and commands, we didn’t didn’t go into any really advanced features so there probably isn’t much more to say. The suite also comes with an iOS Simulator for testing apps on the desktop without deploying to a device. It should be underscored that it’s a simulator, not an emulator. If you have a quad core 64-bit CPU with 8GB of RAM that’s what it’ll use to run your iOS app, so it in no way represents the performance your app will get on an iOS device’s significantly lower-powered hardware. I am a little bit surprised by this, I would’ve thought even if Apple was unwilling or unable to emulate their ARM chip, they might at least restrict the resources available to the device simulator, but no, it just executes the code, and since iOS and OSX are the same core operating system this probably wasn’t too much work.

iOS apps are written using Objective-C, which like most of the underlying OSX code was brought to Apple by the acquisition of Steve Jobs’ other company NeXT. As the name would imply it based on the use of objects, and as I understand it, is a superset of C, so any C code should work under Objective-C. Apple gives you wide series of frameworks  to work with in development. Foundation is the most important one and gives you NSString (strings obviously), NSArray (an array, but more like a C vector in that it has built in functions to use) and NSNumber (a wrapper class that can hold any numerical data type from a bool to a double). Despite these classes you can still use standard C data types (int, float, etc), I don’t know what specific advantages to using Apple’s classes there are, but I suspect they exist. All predefined classes in Cocoa and ones the programmer make inherit from NSObject. This the root class and everything is subclassed from it. As a side note all these class names are preceded by ‘NS’ because this all comes from NeXTSTEP, the OS Apple got from NeXT. The other framework we looked at during the course was UIKit, which is pretty important because it contains all the user interface controls, and you wouldn’t have of an app without a UI.

Actually writing code in Objective-C is similar to regular C. You can declare objects in the same way

NSNumber myNumber = 6;

or if you’re feeling dynamic;

MyClass *myObject = [[MyClass alloc] init];

which more closely resembles the C way of doing things and looks strange and confusing to a programmer like me with C++ experience. Objective-C can get potentially much more wordy when it comes to calling functions though. If you had function declared in C you would call it as shown in the example below.

MyClass::doSomething(string type, int numOfTimes, bool clowns)
{ …blah, blah, blah, implementation… }

myObject.doSomething(“cool”, 5, 1);

In Objective-C the same function call would look like this.

[myObject doSomething type:”cool” numOfTimes:5 clowns:YES];

The thought of having to type that extra code might seems burdensome, but if you use Xcode’s autocompleting it should offset it a bit. The claimed advantage of doing it this way is that Objective-C is self documenting. That first function call in C is ambiguous if just viewed by itself and the programmer would have to include a comment, but Apple’s position is that the Objective-C way makes it clear without comments.

Objective-C also has a form of memory management which is different from simply calling ‘delete’ on objects you create dynamically, like in C++.  iOS doesn’t do garbage collection and objects have to be deallocated from memory when they are no longer needed. This works through each object having a retain count, which is automatically set to 1 when you allocate a new object. Any part of the program using that object should call ‘retain’ on it, which will increment the count. When an object is finished using an object calling ‘release’ with decrement the count. Once the count hits 0 the object will be deallocated. There is also another call called ‘autorelease’ which should be called on functions that return objects before the function returns. This will have the object dellocated automatically once it’s been used.

Paradigms

There were three main design paradigms we covered at the workshop. Like most things to do with Apple, your life will be much easier if you do things their way, and these are paradigms Apple uses heavily, so it’s advisable you do to because they’ve made their dev tools with them in mind.

Target-action is the concept of separating out events from their actions. When an event occurs, instead of processing that event internally, it can send a message to another object that the event has occurred, and that object will handle the necessary actions. This is intended to keep classes general-purpose and maximise code reuse. For example, in the case of a login button (which would be a instance of class UIButton), rather than subclass UIButton and make a custom function to run the login sequence when the button is pressed, the programmer can make a separate login controller object with an action called ‘login’ and set it as the target for that event in the login button object.

[button addTarget:controller action:@selector(login:) forControlEvents:UIControlEventTouchUpInside];

The number of specific events for something as simple as a button press is amazing, I’m pretty sure this one means the button is pressed inside its boundaries and the event triggers when the button is released (going up). When this event occurs the object ‘button’ will send a message to ‘controller’ to carry out the action ‘login’.

Delegation is the paradigm when one object notifies another of it’s behaviour and requests permission to do things. Becoming an object’s delegate is simple;

otherObject.delegate = self;

Self refers to the object this is executed within (let’s say ‘myObject’), so this will set myObject as the delegate for ‘otherObject’. When this occurs otherObject will send messages to myObject which will usually contain one of three keywords; notify that something is about to happen (will), notify something just happened (did) and ask permission to do something (should). For the case of UITextView (which a multiline text box) it has a small collection of delegates responses. When you tap the text box to edit it, it will send textViewShouldBeingEditing to its delegate. The delegate will return a boolean to grant or deny permission to do this. If it is granted it will send textViewDidBeginEditing (or if it isn’t implemented to ask permission) and the delegate can take any necessary action. It also has the same delegate calls for the end of editing and a few others. Similarly to target-action, delegation increases potential code re-use by keeping implementation specific code in separate controller objects so objects like text boxes can be used in many programs with different behaviour without any re-coding necessary.

The third paradigm is model, view, controller. This is yet again another strategy for keeping object functionality independent. This paradigm calls for objects that do one thing without being inseparably  tied to another object to function. iOS apps should be made of model, view, controller (MVC) clusters and apparently Apple does this all the time. The model object stores data, the view object displays that data on screen, and the controllers acts as an intermediary between the two to mange. The view does not directly manipulate the model, and the model does not directly tell the view what to display. The example given was a chess game. The model stores the data representing the state of the game and the view is UI element which displays the game board. The model object is view independent and doesn’t need any information about how the data is displayed. The view object uses target-action and delegation with the controller to get the data to display the game, it doesn’t manage this data, nor does it own it. It would send messages when a player moves a piece and request permission to confirm it based on the move’s validity. Ideally with a properly implemented MVC cluster you should be able to change one part without needing to change anything else. Maybe instead of a view controller that displays graphics, you instead want to generate an ASCII art board (lines of text), you should be able to do this without changing the model or controller since all that code to generate the UI should be internal to the view object and independent.

This is by no means an exhaustive piece, and if you found it interesting, good. It was also good for me to go over this stuff again. I hope to get into some iOS app development later in the year, once I’ve got some sort of OS X setup, my Hackintosh ambitions didn’t go well. Fortunately Xcode is now a free download from the Mac App Store , I think it used to be $5. Unfortunately though is the fee required to join the iOS developer program, it’s $99 per year, and there is no student concession. Microsoft also charges a fee to distribute apps for Windows Phone and Xbox, but they give membership to confirmed students for free, it would be nice if Apple did the same. I suppose if you’re confident you have an app that would sell well it’s an investment you can re-coup. Surely Apple could give students membership for free, not everyone on a limited income wants to pay $99/year, and it would get more student development going.

Anyway, enough ranting about the fee, if I develop something people might actually pay for, I might join the program.

iOS SDK Workshop Day 0: An Apple Odyssey

Thursday I had plenty of time to kill in Perth before I could check into my hotel, so I took some time to visit the Perth Apple Store, as a way to prepare my immune system so I don’t have a bad reaction at the workshop. This is only the second time I’ve been to an Apple Store, Adelaideans are not privileged enough to have an local Apple Store.

IMAG0088

(Isn’t it interesting how Apple makes there stores almost entirely of Windows®.)

The first thing I noticed was how full it was, not just with customers, but with staff. The place was full of hipsters and blue-shirt-wearing purported genii, which aren’t mutually exclusive. It looks more like some sort of trendy internet cafe, which is part of the success of Apple’s retail initiatives. Apple takes a chapter from car companies and treats their stores as showrooms rather than shelves stacked with product boxes, and you’re welcome to simply walk in and check your Facebook updates.

IMAG0085IMAG0084

In the window Apple shows their recommended iPad configuration. To get the most out of your iPad you must buy an additional 11 iPads (with smart covers) to act as an altar for the iPad you use. If your iPad isn’t constantly worshipped it may become moody and you’ll experience performance degradation and app crashes.

This can be yours starting at the breakthrough price of $7,443.00

IMAG0083

In the the other window Apple is showing off their latest product innovation, lead balloons. Apple expects to sell 1,000,000 units of the breakthrough iBlob in the first calendar year. This product is set to revolutionise the lead balloon market, with Jobs stating “it’s the first time anyone has delivered a lead balloon that’s so simple to use, in a gorgeous and thin form factor at a breakthrough price”. The iBlob app store is expected to launch in the third quarter of 2011.

Now I’m all prepared for the workshop, wish me luck.

How to Score a Hotel Upgrade

If you came here looking for the definitive, never-fail trick to getting a room upgrade at a hotel you’re out of luck, but I can share one way which worked for me and I wasn’t even looking for it. It’s also an example of excellent customer service which deserves a mention.

I’m currently in Perth for an Apple University Consortium workshop event. When I was looking for a place to stay I was quite pleased that the Parmelia Hilton Perth’s cheapest room was within the AUC’s allowance for accommodation subsidy because the Hilton is directly next to the workshop venue.

The Parmelia Hilton heavily promotes guest internet service on their website and makes no mention of charge, so I sent an email to the hotel to confirm whether or not it was free of charge, because many hotels charge extra for internet. I got a timely reply.

Thank you for your email and enquiry. Kindly to advise that the internet is provided by a third party company, and therefore it will incur additional cost of $0.55 a minute or capped $29 for 24 hours.

I think that’s an unjustifiably high fee considering I can get internet at home for a month for that price. I understand there are costs associated with provisioning and maintenance, but those prices are insane. I thought not being upfront on their website was a bit misleading, so I replied with some feedback to that effect.

Thankyou for providing me with this information.

I’d like to offer some consumer feedback to you; this information needs to be on your website. If it is already there please direct me to it because it is not obvious. I think that withholding this information on the website is quite misleading. The description for a twin guestroom opens with the phrase “Feel at home in this bright and airy 26m²/280sq.ft room with wireless internet access.”, and the room features lists ‘high speed internet access’ right in between ‘hairdryer’ and ‘iron’ (which I assume are not at additional charge). In my opinion, doing this without even an asterisk and a footnote is borderline deceptive, especially since that is not a nominal fee. I would suggest that it’s unjustifiably high.

I hope you value my feedback and consider revising your website.

Regards,

Craig L

I expected them to take my feedback under consideration and maybe, maybe…. even comp me some internet for my stay, but the response exceeded my expectations., and from none other than the general manager.

Thank you very much for your enquiry and comments concerning Internet facilities in guest rooms. To clarify, the description on our website relates to the features in the room rather than the price. Yours are the first comments I have received, however based on your feedback we will be amending our website.

As a measure of our good intent, we would be pleased if you would accept a complimentary upgrade to a King Deluxe Plus room, valued at $165 per day, for your forthcoming stay in the Hotel.

Thank you for your courtesy and we look forward to welcoming you to the Parmelia Hilton.

This a great example of high level service and making customers feel valued (take notes Vodafone)
So my point is, if you feel you have a valid piece of constructive criticism, share it, handing out an upgrade doesn’t really cost them anything unless all those room types are occupied and they could’ve sold it at regular price.

However, of course, don’t come up with some nitpick, be a jerk about it, and demand the presidential suite.

Props to the Parmelia Hilton Perth for taking customer satisfaction so seriously.

What I paid for:

Twin Guest Room

What I got:

IMAG0089IMAG0090IMAG0091IMAG0092IMAG0093IMAG0094

iOS SDK Workshop Day -1: The Forbidden Fruit

Tomorrow I’ll be jetting off to Perth to participate in an Apple University Consortium iOS SDK Workshop event. One of the Adelaide Uni computer science staff members posted about it on the CS forums and I decided to apply. The application process required me to fill out  four questions, regarding why I wanted to go, how I’d benefit, and how I’d share what I learn with others. I was quite excited when I was notified that I’d been accepted for a place (and not just because it’s a subsidised trip to Perth). I’ve wanted to get into iOS development for a while, regardless of what you may think of it, it’s one of the largest mobile platforms and a developer would be a fool to not take it seriously. A big reason I haven’t done any iOS work is because I haven’t got a Mac to run Xcode on, we’ll see what I can do about that.

The workshop runs over three days, from Friday 29th to Sunday 1st May. I’m flying over from Adelaide tomorrow (Thursday) morning and coming back Sunday night on the red-eye flight via Sydney (potentially unpleasant, but on the upside I can buy Kripsy Kremes), refreshed for the start of the second term of uni.

I’ve never really been much of an Apple enthusiast, some of my friends think I’m going to the dark side, but as I said in my application, a serious computer scientist or software engineer should be familiar with a variety of platforms and environments. Personally I have an Android phone, but I also have an iPod Touch, and my favourite assessment of iOS is that it’s a bit Fisher-Price. I just don’t find it as powerful as Android, and I don’t think it’s supposed to be. iOS also shouldn’t be ignored from a commercial standpoint, Android may have overtaken it in global marketshare, but iOS users seem much more willing to spring for even frivolous paid apps.

I’ve decided to try blogging about my workshop experience, especially since the AUC encourages us to share what we learn. I’m not really sure yet what I’ll write exactly. I might end up just revising what we covered over the day in blog form despite that the same info would probably be available in other places online, hey, they say the best way to learn is to teach.

The only question that remains is; should I wear my Windows Vista shirt?

IMAG0076

Would I risk being flayed by white earbuds?

If Jesus died in the Twentieth Century

Well the Easter weekend has come and gone. For many it’s the annual festival of chocolate consumption, historically it’s the post northern hemisphere vernal equinox celebration when pagan Spring goddesses bring a re-birth of life after the cold darkness of Winter, and of course, many celebrate the Christian Edition, the death and re-birth of Jesus Christ. This is probably the most significant event in the Christian faith, when Jesus was sacrificed for our sins, and his death-by-crucifixion is where the religion’s iconic cross symbol comes from. It’s one of the most recognised symbols in the world, probably rivalling the global recognition of the Coca-Cola logo, but I would like to raise the question, what if Jesus had lived and died in the twentieth century?

I don’t ask this to ponder what his politics would be, but instead to ponder how he’d might’ve been executed and what it might’ve meant for the religion. Imagine seeing people walking around with ornately decorated electric chairs on a chain round their neck, or seeing a large electric chair mounted on top of a place of worship. Catholics typically depict the cross with Jesus on it, imagine going to a Catholic church with a statue of Jesus receiving a jolt of electricity at the front of it. If Christianity had a more contemporarily recognisable method of execution as its symbol I think the whole thing would seem a lot less wholesome and a lot more like some sort of death-cult.

Personally I do find the celebration of human sacrifice distasteful, and there is something vaguely disturbing about seeing individuals and even small children walking around with execution devices hanging around their necks.

Sometimes when it comes to something familiar, it’s good to look at it with new eyes.
I hope I’ve given you something to think about.

(P.S. I’d love to buy some hot electric chair buns)

(P.P.S. Happy Easter)

Relevant cartoon: http://bizarrocomic.blogspot.com/2008/06/electric-chair-religion.html

Further reading: http://www.snopes.com/holidays/easter/easterlore.asp

I Think I’m a Real Blogger Now

In my position it’s easy to get feelings of comfort and isolation. I’m publishing to a small personal blog which gets very few comments. I know friends who click the links on Facebook read my stuff, but I don’t really know if anyone else is. I recently got a jolting reminder that I’m not shouting into a silo, I’m publishing to the open and public internet.

A couple a months ago I had the displeasure of witnessing a very shoddy news report on Wi-Fi courtesy of Ten News. I published my thoughts on the story and outlined why I thought it was a poor piece of journalism. There was a brief section of a man being interviewed on the segment who claimed to be ‘electromagnetic hypersensitive’. This is what I wrote;

They then briefly interview a gentlemen who claims to get physical symptoms when exposed to Wi-Fi, skin tingling and heart palpitations. Coincidentally these could also be symptoms of stress or anxiety. This is often called electro-magnetic hypersensitivity, and there’s not evidence to consider it as a genuine condition. Supposed sufferers have been unable to detect a presence of an EM source when tested in a controlled environment, and researchers suggested they need a conscious or unconscious visual cue to became symptomatic, and also note their symptoms are consistent with stress and respond well to stress treatments.

Like the rest of the article I didn’t go into great elaborations, but it was enough to get the attention of Mr Parker who took the time to post  a comment on my article. I’d like to thank Mr Parker for taking the time and I’ll now respond to his comments.

“Interesting that you reported on segment, and I am the gentleman who made the very brief comment on Wi Fi. Much what I did say wasn’t in the segment, and I agree with you that it said nothing.”

This doesn’t surprise me at all. I’m guessing they performed a long interview, but then when it came to piecing the story together they only cut out the sound bites they needed. In this situation it is easy for a person to have their points reduced or be taken out of context.

“Would glad to debate it with you, seeing that I have been suffering this senstivity for a number of decades, and worked in the military field of communications for many years. I suffered then as well, but didn’t become worse until the airways became proliferated with microwave, and now Wi Fi radiation over the past decade.”

Well again, the ‘sensitivity’ Mr Parker claims to be suffering from hasn’t been confirmed to exist and has evidence against it (that’s not saying that he’s imagining or faking). Researchers at in the Division of Psychological Medicine at King’s College, London in 2005  reviewed 31 studies on alleged electromagnetic hypersensitivity and came to this conclusion;

The symptoms described by “electromagnetic hypersensitivity” sufferers can be severe and are sometimes disabling. However, it has proved difficult to show under blind conditions that exposure to EMF can trigger these symptoms. This suggests that “electromagnetic hypersensitivity” is unrelated to the presence of EMF, although more research into this phenomenon is required.

This systematic review could find no robust evidence to support the existence of a biophysical hypersensitivity to EMF.

Full Report

I also found a more recent study (2007) testing if blinded exposure to mobile phone signals (microwaves) could provoke EMF symptoms, which came to similar conclusion.

Short-term exposure to a typical GSM base station-like signal did not affect well-being or physiological functions in sensitive or control individuals. Sensitive individuals reported elevated levels of arousal when exposed to a UMTS signal. Further analysis, however, indicated that this difference was likely to be due to the effect of order of exposure rather than the exposure itself.

The present data, along with current scientific evidence, led to the conclusion that short-term rf-emf exposure from mobile phone technology is not related to levels of well-being or physical symptoms in IEI-EMF individuals. Furthermore, IEI-EMF individuals are unable to detect the presence of rf-emf under double-blind conditions. It remains, however, that IEI-EMF individuals present with a range of distressing and serious symptoms and often have a very poor quality of life. Given the current findings, together with findings of related research (Rubin et al. 2005), it is imperative to determine what factors other than low-level rf-emf exposure could be possible causes of the symptoms suffered by IEI-EMF individuals, so that appropriate treatment strategies can be developed.

Full Report

I think it’s fair to say that alleged EM hypersensitivity is very unlikely to actually be the result of regular EMF exposure. Parker says that his symptoms have increased over the decades as more broadcast stations have been setup, but many things have changed over the last few decades, so their are plenty of things you could draw casual correlations with. What you need is controlled, blinded testing, and this fails to support the EMF hypothesis.

“Yep, those enclosed room tests is like giving you a placebo test as it doesn’t prove anything, because every one has their own characteristics of suffering, because ELF is another offender, but the government believes that by increasing the safety regulations from 100 milli gauss to 1000 milli gauss, then they cover themselves.”

Firstly, don’t use that word ‘prove’ because that refers to absolute certainty. To test a claim like this, controlled and blinded experiments are the only valid method and the results of these do indicate that EMF hypersensitivity is not a genuine condition. What is said after is an attempt to shift the goalposts. Everything so far has been about microwaves, including the news story I was responding too. Bringing up extremely lower frequency fields and government regulations is a deflection that does not address the point. I haven’t even heard of anyone claiming to be hypersensitive to ELF fields.

“I can assure you that it’s not a mental disorder,”

If ‘mental disorder’ is supposed to mean the suffering isn’t real, then I don’t think anyone is saying it is, and I don’t think I implied this either, however there is research, such as this study from Sweden, that suggests at least some people’s supposed EMF suffering could be psychogenic.

The patients in the experimental group reduced their evaluations of the disability more than the control group did. This indicates that psychological treatment may be of value in this disease. However, none of the psychophysiological measures or the subjective reactions to the provocation test showed any significant between-group difference. The conclusion from the provocation test is that this group of alleged hypersensitive patients did not react to the electromagnetic fields.

Abstract

“and the hypersensitivity is also a causation faction or Myaligic Encephymyolitis (ME), Chronic Fatigue Syndrome (CFS), Irritable Bowel Syndrome (IBS), and Burning Mouth Syndrome (BMS), which are illnesses that the medicos have no idea what causes it but they know it effects the nervous system. But, if you try to lead them to EMR and EMF as a causation factor, they don’t want to know you, and ask you to leave.”

Firstly, those are unbacked assertions unless some evidence can be put forward. Secondly, this paragraph is contradictory because it asserts that EMF can be ‘causation factors’ for a list of conditions, but then says medical professionals ‘have no idea what causes’ them. If a lay-person thinks they know something that the body of medical professionals does not, they would have to be in possession of some very substantial evidence, and so far Mr Parker has presented none. He says that doctors ‘don’t want to know him’, and ‘ask him to leave’. I doubt it’s as simple as this (i.e. I doubt the mere mention of EMFs would get him kicked out of the clinic), but, to Mr Parker, maybe that should tell you something about the plausibility and evidence base of what you are suggesting.

“Well if you are conversant with WHO, then they stated that ME and CFS is a central nervous system disorder.”

This is of no relevance whatsoever.

I hope Mr Parker finds my response satisfactory. To reinforce what I’ve said, I’m not suggesting that the suffering that Mr Parker describes isn’t real, I’m suggesting it’s not the result of expose to Wi-Fi and other electromagnetic fields, which the evidence supports. I also submit that continuing to push the EMF hypersensitivity message is a waste of resources and attention, which could otherwise be directed to finding the true cause of the suffering.

I’m so Proud of my Alma Mater

Anyone who’s read my blog regularly since its inception probably knows I have objections with the companies and individuals that promote Power Balance products. It’s a pseudoscientific product line which became quite popular in Australia. The only valid debate is whether it’s bad science, anti-science or pseudoscience.

Anyway, through a series of events I visited the homepage of my former primary school, West Lakes Shore Schools. I found out through Facebook they had taken down a building, and they’d had others built as part of “Building the Education Revolution”. This lead me to looking at the website and I thought I’d have a look at the latest newsletter, see what’s happening 6 years after I left. I saw this and it warmed my skeptical heart.

WLSS PB

It must’ve been fairly common for children to be wearing these if it got a newsletter mention. I’m amazed that parents would be paying $60 for their children to wear these cheap (to make) rubber wristbands. Is performance in primary school sports really that important? It’s good to see an educational institution saying unambiguously that these products are not evidence-based.

I do have one nitpick though, it wasn’t an ACCC ruling, it was an admission by the manufacturer. This might be a bit trivial for a primary school newsletter, but in general it’s an important distinction.

From the wording of this excerpt it sounds like the bracelets have been effectively banned. I don’t really have a particular objection to this, I’ll save my libertarian outrage for more important things. I do wonder though, how big a deal the staff are making about this and to what degree it’ll be enforced. If a child’s wearing one, will the teacher tell them to take it off and confiscate it, or will they brush it off and focus on more important matters? I’m just curious, that’s all.

Congratulations to West Lakes Shore Schools, you win the first Bytes of Wisdom Award for the Promotion of Reality.