Dynamic Properties in Objective-C

In a side project I needed a way to have some kind of proxy object, where all properties, which are defined as @dynamic, where handled by generic getters and setters. I build a small example project to share this solution. So if you need something similar, just copy and paste the snippets you need.

With this you can define your properties as usual in the interface …

@interface DPTestObject : DPObject
@property (nonatomic, readwrite) NSString *name;
@end

… and mark them as dynamic in the implementation.

@implementation DPTestObject
@dynamic name;
@end

Then, setting a property results into a populated dictionary:

DPTestObject *object = [[DPTestObject alloc] init];
object.name = @"Peter";

NSLog(@"values: %@", object.values);
>>> @{@"name": @"Peter"}

You can find the example project on my GitHub page.

Weiterlesen

Tobias Kräntzer

Mai 14, 2013

Heise berichtet, dass Microsoft alle über Skype gesendeten Daten auswertet. Das ist wieder einmal ein schönes Beispiel dafür, dass die Kontrolle der Infrastrukturen nicht einigen großen Konzernen überlassen werden sollte, sondern eine verteilte Infrastruktur anzustreben ist, in der unter Umstanden auch Teile selbst betreiben werden können. Würde dieser Vorfall bei einem kleinen Dienstleister auftreten, wären (1) nicht alle Benutzer betroffen und (2) die Kunden schnell bei der Konkurrenz.

View Controller Collection Controller

With UICollectionView Apple introduced in iOS 6 a great way to build views with a set of elements and separately define the layout. You specify your data source in a controller (best by subclassing UICollectionViewController). The desired layout can then be set as a property. This allows the reuse of designs and also provides a separation between content and design.

With this in mind I thought, why shouldn’t I arrange my UIViewController in the same way. So I build a UIViewController which acts as a collection controller for other UIViewController and uses a UICollectionView for the layout. Weiterlesen