日本

Fun with Objective-C

Posted on

Last week I had the chance to look at my Sempais amazing new iOS app he built on his own which he did for fun. And let me tell you, it was gorgeous. It was far from complete, but what he wrote was an app that would show a mobile version of a browser interface. That interface has his bookmarks neatly organized into specific categories on Chrome.

I thought “wow, that’s amazing! I want to build something like this too” so I decided to have a go at Objective-C this weekend.

This … isn’t a tutorial at all but I thought for self reminder I should put this here.

This link ( https://developer.apple.com/library/ios/referencelibrary/GettingStarted/RoadMapiOS/ThirdTutorial.html ) is my reference to building a simple To-Do list by Apple. The problem was last night I had written this code to add my text objects into the list through this method:

-(void)loadInitialData {
    ToDoItem *item1 = [[ToDoItem alloc] init];
    item1.itemName = @"Buy milk";
    [self.toDoItems addObject:item1];
    
    ToDoItem *item2 = [[ToDoItem alloc] init];
    item2.itemName = @"Buy eggs";
    [self.toDoItems addObject:item2];
    
    ToDoItem *item3 = [[ToDoItem alloc] init];
    item3.itemName = @"Read a book";
    [self.toDoItems addObject:item3];
    
}

However when I build this, I get an error something like “NSMutableArray exception” ..
looking through the docs ( https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSMutableArray_Class/#//apple_ref/occ/instm/NSMutableArray/addObject: ) it says that anything addObject gets thrown which is Nil would throw an exception. So the problem mean’t that what I was adding to my array was either of NULL value or my declarations are wrong.

After checking through what I had written last, I discovered this morning my problem was here in this method:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"reuseIdentifier" forIndexPath:indexPath];
    
    // catch approproate item in the toDoItems array and set the name of that item to display in the cell
    ToDoItem *toDoItem = [self.toDoItems objectAtIndex:indexPath.row];
    cell.textLabel.text = toDoItem.itemName;
    return cell;
}

My placeholder was declared in the source as @”reuseIdentifier”, which doesn’t exist . In my Main.Storyboard, under To-Do-List scene > Table View > my cell was named @”reuseIdentifier”.

A quick modification from above to the following method would then insure that the compiler knows where and what to do with my passed data:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ListPrototypeCell" forIndexPath:indexPath];
    ToDoItem *toDoItem =[self.toDoItems objectAtIndex:indexPath.row];
    cell.textLabel.text = toDoItem.itemName;
    return cell;
}

Hitting build would now display my app without errors.

Advertisements

BBQ & Japan updates

Video Posted on Updated on

It’s been another month since I last updated and as expected a lot of things have happened.

I used to work at a chinese restaurant the school got me. And while I am grateful for their efforts I didnt like it very much. It was good to work with Japanese chefs but there was absolutely no time to talk freely since it was always busy. But other than that I was just washing dishes and maybe cooking a little but not much. Carrying hot plates straight out of the machine did some damage to my hands so part of my skin in my fingers kinda melted off a bit and now i have to moisturize it like crazy.

Good news is though I quit that job over a week ago and I now work for Seven Eleven, which is a 24 hours convenience store all over Japan … kinda as popular as Starbucks now that I think about it. Seriously, theyre everywhere. I found the job and applied by myself and got it within that week. So now I have more chances to work with Japanese people and talk to them freely and theyre all extremely nice people too!

School was on a 1 1/2 month Summer break and 2-3 weeks later we’re now in Autumn break for a week. It’s … well I haven’t got any complaints because I still study but its nice to have someone help me in a while.

 

1267766_448923848555585_2031425408_o

A few days ago me and some friends went to a BBQ with the owner of the Japanese bar Rough Times. They don’t have a website but they are mentioned here in a food blog site:

http://tabelog.com/fukuoka/A4008/A400802/40025518/

Just to better explain what sort of life I have in Japan I made a video and decided to upload it here! So without rambling on, please check it out in HD

Laters!

《The Last Samurai 翻訳》 + small update

Posted on Updated on

Hi, Sorry I haven’t updated in a very long time. But to make it brief on the last one:

1) I’m finally leaving my part time job in that chinese restaurant because I got hired at an even better place to work, closer, better environment and better experience. Pay wise, not so much different. Still, good.

 

2) Studying has been on and off, but made up a lot in a lot of non english leisure time (films, books & friends etc)

3) It’s been pretty hot. Sweating like crazy.

 

Anyway I few weeks ago or two I watched The Last Samurai and one part of the movie got me thinking on how to translate it in my own words. So I finally got to it and here it is:

 

“From the moment they wake they devote themselves to the perfection of whatever they pursue. I have never seen such discipline. I am surprised to learn that the word ‘Samurai’ means‘to serve’…” 

「起きる瞬間から目的まで一部たりともミスのないように、彼らはそれなりに前進する。私はこれ程の自制心そのものを見たことがない。侍というのは誰かのためにこうするわけだとはね」

 

また更新するからお楽しみ

Ben