picture

Objective-C: Difference between weak and assign

April 1st, 2014

So, what is the difference between weak and assign?

@property (nonatomic, weak)id<YourDelegate> delegate;

VS.

@property (nonatomic, assign) id<YourDelegate> delegate;

As I understand, the only difference between weak and assign is that if the object of a weak property is deallocated, the value of the weak pointer will be set to nil. Using weak properties prevents accessing memory garbage.

If you use assign, and the value object is deallocated, the value of the assign-property points to garbage.

I haven’t come across use cases so far, when the usage of assign-properties would be of advantage. My recommendation: use weak-properties to avoid problems! ;-)

Open Source Programs for MAC and PC

March 24th, 2014

I’m subscribed to XING`s IT-news which I regularly get per email. Today I found a nice article about useful free software for MAC and PC which I’d like to repost:

http://www.moneysavingexpert.com/shopping/free-office-software

Tools: Tidy XML with TextWrangler

January 27th, 2014

The following tip is for TextWrangler users of version 4.5.6 and greater. If you want XML files look nice in TextWrangler follow these instructions:

- create a new script file, e.g. TidyXml.sh with following content


#!/bin/sh
XMLLINT_INDENT=$'\t' xmllint --format --encode utf-8 -

and save it under

/Users/[UserFolder]/Library/Application Support/TextWrangler/Text Filters

That’s all! now just open your XML file, got to menu Text->Apply Text Filter and choose your script file.

iOS: Singleton Pattern with Objective-C

December 27th, 2013

Find below the way Apple recommends to implement singleton in your code. In your .h file you should declare a static method:

+ (YourClassName*)sharedInstance; 

Afterwards go to your .m file and implement the declared static method:

+ (YourClassName*)sharedInstance 
{
	// Create a singelton using GCD (thread safe!)
	static YourClassName * sharedInstance = nil;
	static dispatch_once_t onceToken = 0;
	dispatch_once(&onceToken, ^{
		sharedInstance = [[YourClassName alloc] init];
	});
	return sharedInstance;
}

This is a thread safe implementation of the singleton pattern! I always used Java-like singleton implementation in the past, but then I found the described way.

Don-Wave Website

December 23rd, 2013

This weekend I set up a website for a shipbroker company don-wave. To keep the things simple I decided to make use of the popular cms wordpress. Read the rest of this entry »

Objective-C: Private Properties

October 30th, 2013

What I really miss about Objective-C is the clear concept of functions(properties) visibility like the way it is realized in JAVA – static/public/protected/private. Today I found out the way of using “private” properties/functions in your Objective-C class. In your .m file just define the interface with the property you need (ARC):


@interface MyClass ()

@property (nonatomic, strong) NSArray *someArray;

@end

@implementation MyClass
  // ...
  // your implementation
  // ...
@end

Note: “nowadays” it is possible to omit the @synthesize line

Setting up Jenkins on Mac for iOS Projects

October 8th, 2013

I have had already experience of setting up Jenkins for automated builds of iOS projects. However, in cases I had before, there was a Linux or Windows machine with installed Jenkins server. A dedicated Mac machine was added as Jenkins-node. Read the rest of this entry »