Printing every possible combinations of ABC (Swift 2.2 )

Posted on Updated on

I had time this evening .. so I figured why not dig up some example code I copied from a tutorial online and modify it to show every possible combinations of the letters A, B and C.

Only this time instead of showing through a terminal I would print it on an iPhone app. So here it is ..

スクリーンショット 2016-03-28 21.19.43

Source code:

import UIKit

class ViewController: UIViewController
    @IBOutlet weak  var totalPermutations: UILabel!         // print total permutations count of ABC
    @IBOutlet weak  var _comboTextView: UITextView!         // print every combination of ABC
    @IBOutlet       var _outputLabel: UILabel!
                    var _currentCount = 0

    let combinationsArray: [String] = ["A", "B", "C"]

     * Initialization
    override func viewDidLoad()

     * Print every combination of ABC
    func printCombinations()
        var totalCombinations = 0
        var str: String = ""
        for letter in combinationsArray {
            for nextLetter in combinationsArray {
                for nextNextLetter in combinationsArray {
                    str += (letter + nextLetter + nextNextLetter + "\n")
        totalPermutations.text = ("Permutations: " + String(totalCombinations))
        _comboTextView.text = str

     * Memory warning
    override func didReceiveMemoryWarning()

     * Start counting
    @IBAction func addOneButton(sender: UIButton)
        _outputLabel.text = "クリック回数は:\(_currentCount)"
        _outputLabel.textColor = UIColor.redColor()

Edit: Added total permutations counter


The Angry GF (A non-released Unity, C# Game for Android & iOS)

Posted on Updated on

スクリーンショット 2015-10-31 10.29.39
For a few months I’ve been working on a simple retro-style “flicking” game for Android & iOS. A lot has changed during the production and well .. long story short: My idea wasn’t good enough.

So why not release it as open source? Makes sense. Plus a lot of people out there need some information which I’m giving away for free and that itself makes me happy 🙂


You can download the entire source code and its resources (except BGM because I didn’t make them) from my Github:

Samurai Gunship website finally released!

Posted on

Working at Pamprepps Games in Fukuoka Japan is awesome!
Today the official website for the game I developed for Android (iOS is coming soon) has been released!

スクリーンショット 2015-09-14 11.45.37

Link →

Installation Failed: Invalid Argument – iOS Simulator & XCode 6.4

Posted on Updated on

I had this error since yesterday and couldn’t figure out what was causing this.

Tl:dr – Check your Resources folder in your project folder and make sure you don’t have copies. Then add them properly into your workspace in XCode.

The detailed version:
My initial thoughts was my Bundle name, identifier and product name were different but changing either wouldn’t work. But then I ran into this thread:

Update: Xcode doesn’t like it when you have a referenced directory called ‘Resources’ within your resource bundle.. but instead of complaining about this, you end up wasting half the day trying to resolve all the other issues that it throws up at you instead (see previous two posts).

All is now resolved and working as it should.

Looking at my work tree I had 2 Resources folders. One under my project folder and another inside my proj.ios_mac folder. Not only that I had the contents of my Resources folder copied within proj.ios_mac!

Deleting these copies, selecting “Add files to [project]” eventually did the trick.

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 ( ) 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 ( ) 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.