Prime Number Check-er


My First Cocoa App

Hoping to make this the first of many Xcode related posts. I made my first foray into Objective-C Cocoa today with a prime number checker. Ignoring the UI code and other extremely Apple-specific bits of code, here is the heart of the app:

- (IBAction)button:(id)sender {
    long int aNumber = [_text integerValue];
    int checker = -1;
for(long int k = 3; k <= (0.5*(aNumber)); ++k){
 if(aNumber%k == 0){ checker = 0; }
    } 
    if(aNumber == 1 || aNumber == 2) {checker = 1; }
    if(aNumber == 4){checker = 0;}    
    if(checker == 0) { [_label setStringValue:@"Not A Prime Number!"]; }
    else { [_label setStringValue:@"Prime Number!"]; } 
}

You are also free to download the app, although I’m not sure why you would want to!

Primely

Propaganda for the next Cold War

UK Foreign Secretary William Hague this week warned of an impending “Cold War” if Iran was allowed to continue its pursuit of nuclear weapons. However, to soften the blow, Mr Hague did insist that military action was not being considered.

Although direct military action is not being supported by Western governments, the sudden increase in Iran-related chatter by senior politicians points towards a gentle attempt to shape public opinion. This is not necessarily malicious, but simply an attempt to ensure the public (and oil prices) are not alarmed if an Iran-Israel conflict occurs.

Starting with the assassination of Nuclear scientists in Iran earlier this year, we are now witnessing the beginnings of a spiral of escalation that could lead to war. This was responded by “retaliation” attacks on Israeli diplomats in Thailand, an unsuccessful attempt to continue the covert warfare that has already begun. However, the next steps are far from covert. Iran’s dispatching of its warship, through the Suez canal is the strongest signal yet that further provocation by Israel and the West will not be treated passively any further.

What is next? We are reaching a point of no return in the relationship between Iran and the Western world. Most European leaders have been so far willing to support rudimentary sanctions but shown strong reluctance to any suggestions of severe action. This has really shifted the focus onto America and her closest allies such as Israel and the UK. Iran’s response to the latest EU sanctions is to halt oil exports before the restrictions take effect, showing a new proactive “response” to international hostility. Supported by the retaliation attacks on Israeli diplomats, my theory is that Iran has now been pushed to the edge of what it feels is wholly inappropriate treatment. Every attack, be it economic, covert or overt warfare will be reciprocated.

The UK and US economies are only just showing signs of recovery and with Obama heading towards elections, complications are unwelcome. Therefore a two-sided approach of preparing the public for the worst and tightening the reins on Israel’s ambitions is only logical. Unfortunately, the cynic within me believes these measures are only temporary. In the long term, Iran’s nuclear pursuit is something the US would prefer to eliminate. Once Obama has secured his second term as President, he will be granted the freedom to make unpopular and controversial decisions without the negative consequences. It is then that I believe Israel will be allowed to act as it desires, predictably destabilising a region already on the knife-edge. The only uncertainty is whether the name “New Cold War” will stick.

Man On a Ledge – A perfectly good movie ruined

Munching away on my popcorn 90 minutes into Man on a Ledge, I had decided that I was enjoying the mindless superficial action on offer. I did not walk into the theatre expecting anything fantastic so I guess you could say I was pleasantly surprised. The final scene changes everything. After an hour and a half of borderline believability Sam Worthington proceeds to jump off his “ledge” starting a chain of events which will require you to suspend your disbelief like never before. In the space of twenty seconds the protagonist goes from perilous situation to release from prison. The most accurate phrase for my feelings at this point is premature climax. Suffice to say that the film falls apart at the most crucial scene.

I cannot fathom why a director, or in fact ANYONE involved with Man on a Ledge would allow this final rush of absurdity to occur. Of course, you could say this movie was never intended to seek critical acclaim. For me, this is not good enough. The final scene forms your lasting impression of the movie. The greatest recent example of a stunning final scene was Christopher Nolan’s Inception. Thought-provoking, simple, memorable. It forces further discussion. Man on a Ledge’s ending is the antithesis. In fact, I am so enraged by this that I feel the only fitting commentary remaining would be to end this prematurely.