|
|
By gherlein, on January 4th, 2012 - Comments closed Much teeth gnashing tonight. I am working on my next game idea – another kids math game using cocos2d. It took me quite a while to figure out that if I add a label to a sprite – in this case, the math number to be answered – that it inherits from the scale of it’s parent. If you stop to think about it, of course it does. But the way it manifested was an apparent invisible label where otherwise it should be there.
Silly programmer. Word to the wise: when adding children, think carefully about the attributes being inherited.
By gherlein, on January 4th, 2012 - Comments closed There’s not as much on KVO when you google as there is on other forms of object-to-object communication. I found a lot on Notification, for example. But KVO is potentially much simpler. I suspect that Notification is used more often because you can do a ‘chain of responsibility’ for an event as opposed to just assigning an observer. However, just having an observer in a controller that can watch a particular property in another object and get notified of changes is a powerful and simple way to solve a whole class of problems.
I found that that the API has a few gotchas so I thought I’d jot this down to help others if possible. The first thing you have to do is have an object with a property you want to observe. Note that this must be a property and not merely an instance variable – and the variable must not be readonly. Next, you must tell the object that it should report changes to that property. You do this from where the object can be seen, not from within the object. If you have an object ‘obj’ with a property ‘event’ you would do this:
[obj addObserver:self forKeyPath:@"event" options:NSKeyValueObservingOptionNew context:nil];
Here’s the gotcha though: contrary to some of the examples you see in google searches, you cannot set options to 0. It’s a bit mask without a useful default value, so you need to set it. You probably want to know the new value of the property in the message, so you should set it to NSKeyValueObservingOptionNew. If you set it to 0 it will just silently fail to send messages.
Next, in the object doing the observing you need to implement the NSKeyValueObserving Protocol. Here’s a simple example:
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object
change:(NSDictionary *)change
context:(void *)context
{
if ([keyPath isEqualToString:@"event"] )
{
// process here
}
}
Now there’s one more gotcha: when you change the value of the property in your object, you must use self to force the use of the setter. For example, you must say:
self.event=NEW_VALUE;
and not just say:
event=NEW_VALUE;
The observer sub-system is tied into the getter and setter methods synthesized as the property.
I hope this helps someone!
[UPDATED]
There’s a great discussion on Hacker News about this – pointing out that I did not use the context pointer when I should have. I learn yet more about this API. You can follow the conversation here.
By gherlein, on December 28th, 2011 - Comments closed 2011 is almost gone. What a year of change it’s been. I set a goal to build my reader base on the blog to 1000 daily readers. I’m under a hundred. For some reason I have been reluctant to blog for the second half of this year. Sure, I was busy – I took over as VP Engineering at PRN, wrote an iPhone app on my own, vacationed in Colorado… but really, I could have blogged. I think this year has been a time of reflection and consideration for me.
I’m going to do better. 2012 will be a year of more writing. Watch this space! And in the meantime, Happy Holidays!
By gherlein, on November 29th, 2011 - Comments closed My wife’s Grandfather passed away on Thanksgiving evening. He was almost 99. A few weeks ago he was mobile (with a walker) moving around the house, watching ball games and trash TV (he loved the Judge Judy type shows). He couldn’t hear without his hearing aid in – and even then not so well. But his mind was sharp and he laughed a lot. He enjoyed having his Great-Grandkids (my children) around. He was sad to see his other Great-Granddaughter move to Colorado last month, but happy to have her there with her Mom and brother starting her life adventure.

Eddie’s family was from Southern Italy, much to the dismay of his wife’s family from the very far North. He loved to eat good food and drink scotch. Cheap scotch, unless someone else was treating. He was of that generation who remembered the Great Depression and he pinched a penny hard. But he lived very well after retiring from Bank of America. After he retired he travelled extensively and spent time in Mazatlan Mexico every spring and fall until he was in his mid-90′s. An enduring memory I have is Eddie fishing on the beach in Mazatlan as brown as can be. I swear he could tan under florescent lights, but in the warm Mexican sun he’d turn so brown he was almost black! And he ate well! With Italian cooks around him his whole life he got such fantastic meals. We’d sit after a dinner and talk about all the other meals we’d eaten, the places we’d been, the drinks we’d enjoyed. And Eddie did like a drink! I’d often joke that I never saw him drink anything other than coffee in the morning, wine with meals, and scotch anytime he could. And the occasional beer. Just a few weeks ago we sat in his living room (his house is next to mine, sharing a backyard) watching the 49ers. I’d brought him a good beer (Lagunitas IPA). He’d say “now, that’s a good beer!”
And then he fell.
He probably broke both the collarbone and the shoulder blade, they say. Nothing they could do about it other than treat the pain. The walker wasn’t an option anymore – putting any weight on the shoulder was agony. So we put him in a wheelchair and I helped him into it in the morning, out of it to go to the toilet or to bed. His appetite dwindled to nothing. The pain was terrible unless we gave him enough pain pills – and then he’d talk to the paint. But we adjusted the does as best as we could to make him comfortable. Within a few days he was having a lot of trouble even moving his legs at all to get into or out of bed. And last Wednesday night we knew after barely getting him into bed that we didn’t have the ability to get him of it again. We prepared for bed rest and all that would entail. A nurse came on Thanksgiving day to teach us some turning techniques and to check on him (she was a Saint, by the way). Turning him on the bed was very painful and the nurse got his pain medicine dose increased, which thankfully put him to sleep.
And that evening he passed away. Thankfully he did not suffer (beyond the pain of the broken shoulder). He did not get bed sores, or suffer the indignity of losing control of body functions while in bed. Eddie would have been mortified by that. He was a very proud man. He suffered through none of that. He passed away in his sleep with his family around him.
We know he’s in a much better place, and he lived a great life full of adventure and travel. He had family around him constantly. He had a great life. But we miss him terribly.
God’s Speed Eddie. Wherever you are, have a few glasses of their best scotch on me, will you?
By gherlein, on November 15th, 2011 - Comments closed I just reserved an iPhone 4S for pickup tomorrow. I plan to turn off my Blackberry. Of course, my day job only supports the ancient, slowly dying behemoth that is RIM. Oh well. I’ll pay extra for the tethering option and use my notebook to access work email over VPN. Frankly, it’s better than paying the same dollars for an Enterprise Blackberry plan that gives me access to corporate email and an increasingly sucky mobile computing experience. Today I swapped twitter clients, trying a new one. And had to reboot my phone each time. What? Really? A REBOOT to delete an app? Come on RIM, what century are we in? And which twitter clients do you support? Seriously? Did you fall off a cliff? Oh, wait… you did. What developer in their right mind would still support Blackberry?
I’m not some young kid demanding only the latest with no appreciation for the past. I learned cobol on punch cards. I coded my first program on a TRS-80 with 4K of RAM (yes, you young punks, there once was a computer that small). The first computer I bought with my own money was an Osbourne. I still remember how excited I was that Linux was ported to the Zaurus. But I’ve also written Android code and published a game for the iPhone (MultiAlien). The world has moved on, and fast. It’s about the web. It’s about modern operating systems. My expectations are that modern vendors follow the curve. I’d still be chasing Android if Google had not risked the livelihood of their whole ecosystem with their ignorance of Intellectual Property rights (which means that Larry will get an even better boat for the next America Cup race). The only reason RIM has a market at all is that they have tentacles into corporate IT email. When that is gone… the company value plummets to NOTHING. I’m serious. They have NOTHING that I want. And when that cliff hits… you don’t want to have a Blackberry. And I have carried a Blackberry for 7 years. Until tomorrow.
Frankly, the game has changed. I’ll pass on corporate email – or jump through a hoop to read it – to get the rest of the benefits of a real modern mobile device. A real browser. Modern enhancements. A real developer ecosystem. Hope for tomorrow. If nothing else, the phone you carry says something about you. With it? Or dinosaur?
RIM, you are dead and too stupid to know it yet. Buying QNX? What dope did you smoke? But at least you still have some kind of play. Microsoft? Who? For the first time in my professional career they don’t matter. Neither does Nokia. I carried Nokia devices for years and literally prayed for the N800 to change the world. But the game has changed, and Apple has carried the day. Microsoft does not matter. Nokia does not matter.
And as of tomorrow, for me, neither does RIM. Siri, what time can I pick up my new phone tomorrow?
By gherlein, on October 26th, 2011 - Comments closed I’ve started looking at javascript frameworks. Things to like: MVC, forward looking to HTML5, open source, power of Flex without Flash, etc. The most popular seems to be SproutCore, Knockout, and Backbone. Yes? No? What do you like? Contribute to the conversation on Hacker News.
By gherlein, on September 12th, 2011 - Comments closed One of the perils of my news ingest habits is that I don’t always catch the breadth of news I used to. When I read the paper – even a crap paper like my San Francisco Chronicle – I’d see snips of news of a wide nature. I don’t watch TV news. CNN headlines – even by RSS – cover the least interesting spread you can imagine. I have to admit that these days I’m following twitter feeds and about 50 RSS feeds – but most of them are on technology and patent topics: things that have my fancy at this moment.
So I’m guilty of missing a story that ran weeks ago but played out yesterday. Firefighters were not invited to the 9/11 Memorial in NYC because ‘there wasn’t enough space.’ Really? I thought this was a joke of some kind when I heard it yesterday. Seriously? I get it, there’s not a lot of space at the memorial site. Yes, the families must be there. But it could have been possible to have at least some of the first responders present. One per firehouse perhaps. I bet if the Mayor’s office had invited the leadership of the fire department to sit down as part of the planning process a plan could have been worked out. Instead there was an announcement that “we don’t have room for you, sorry.” Unbelievable.
I’m not seeing any real national coverage, so maybe this blew over and smarter heads prevailed. But that it never got the reaction it should have really makes me angry. All of NYC should have been in the streets demanding Bloomberg respect those brave souls. All the National Press should have run stories. Obama himself should have demanded them to be present. The raw stupidity of even pondering for a second that they would not be front and center… it’s mind boggling. There’s no excuse for this not being a MUCH bigger story.
Except that we Americans can be such a fickle lot. What have you done for me lately? Oh that? That was a while ago.
It did not used to be that way. Once upon a time we held memories. We cherished them. We remembered those who risked -and gave – it all.
Here’s the rub: the firefighters didn’t do anything unusual for them that bright Tuesday ten years ago. They do that stuff every day and every night. They rush into flames and mayhem and save lives. They protect property. They risk death and lung shredding fumes and crippling injury and disfiguring burns – every day. They never stopped that behavior.
But apparently the Mayor’s office in NYC stopped remembering. The lack of massive protests by NYC residents means they may have stopped remembering. The lack of national press means the US might have stopped remembering.
But not me. I remember. And I say to those who forgot: SHAME ON YOU. The first responders won’t forget when it comes time to race into a burning building to save you or your kids. They won’t forget. Because that’s who they are. May we all be more like them.
By gherlein, on August 23rd, 2011 - Comments closed There are reports that United Continental will deploy 11,000 iPads to pilots to get to a paperless flight deck. Another accretion of snow on the giant iPad snowball that’s picking up speed. The tablet wars are over. iPad has won. HP sensed it early and got out. It will be interesting to see what Samsung does.
By gherlein, on August 19th, 2011 - Comments closed In my search to market my math arcade game MultiAlien I’ve come across some really good web sites that I wanted to share. Here they are in no special order:
MathFour – Math is not a Four Letter Word!
BestKidsApps - reviews of all the best kids apps
Apps4Kids - another set of reviews – and a place where I bought my first online ad
iPhoneMom - a mother of four does this site – I love it!
MomsWithApps – a site creating a community of parents and parents who make apps – a GREAT idea! I’ll be active there as soon as they approve my registration
[UPDATE}
I Education Apps Review - a site dedicated to review of educational apps
Kids Apps Mobi
The iKids Blog
I’m sure there are more – I’m finding more daily! I’d love to hear about them. The spam in my blog comments got so bad I had to turn it off – but perhaps the best way to message me is through twitter. My contact data is on the left side bar. Follow me and send me a direct message (DM). I’d love to hear from you.
By gherlein, on August 17th, 2011 - Comments closed The kids are headed back to school. My kids start next week, but a lot of folks I know headed back this week. And lots of folks are about to find out that their kids forgot a lot over the summer. I have a solution that the kids will love! I wrote a game especially for this: MultiAlien. It’s available on the Apple App store now.
MultiAlien got a great write up on MathFour – a great site that correctly takes the point that math is not a four letter word! They loved it! One very apt negative comment was that I needed to add a resume feature. I’ve done that and the new version (1.006) is in the app store for approval now. It should be available as a free update in a week or less. But Bon Crowder (the creator of MathFour) points out some interesting things that he and I discussed but I’ve not posted about before: games like this open up different learning channels in the brain. Trying to dodge an alien ship and still shoot the right answer to a question forces your brain to create new paths for that memory. I did a lot of thinking about this long ago when I was on nuclear subs and we had to do drill after drill on the basics: fire, flood, battle, radiation leak, etc. When you drill with more going on than jus stating an answer for a test you really start to know that material. That was one of the inspirations for how I did this game. I’ll be writing more on this in later posts, and I suspect that Bon will be too.
Anyway, please check out MultiAlien. If you want a free code to download it and can promise to tell people about it, let me know. My email is gherlein <at> herlein.com – do the usual substitution of @ for <at> (must at least try to hide from spammers). I’m also very interested to hear about other similar games, education theory and learnings, and your thoughts on the game.
I’ve learned a lot about both game development and iOS/iPhone building this game. I’ll be posting more on that in the coming month too. But for now, back to vacation!
|
|