3 ms·
Objective-C is always going to win the contest for Smalltalk-esque verbosity, but I would hardly consider the code you wrote to be cumbersome. In the modern Obj
by bonch 15y ago
Objective-C is always going to win the contest for Smalltalk-esque verbosity, but I would hardly consider the code you wrote to be cumbersome. In the modern Objective-C runtime using garbage collection, you can write this:
// Order.h
#import <Foundation/Foundation.h>
@interface Order : NSObject
@property (copy) NSString *id;
@property (retain) Customer *customer;
@property (copy) NSDate *timestamp;
@property (copy) NSString *productId;
@end
// Order.m
#import "Order.h"
@implementation Article
@synthesize id;
@synthesize customer;
@synthesize timestamp;
@synthesize productId;
@end
Apple engineers have confirmed that they're working on making @synthesize the default behavior for properties, so eventually you won't have to write that either. A real-world app would be using Core Data for its model objects, negating the need to write this class at all while adding automatic faulting, data integrity, and undo/redo:
Order *order = [NSEntityDescription insertNewObjectForEntityForName:@"Order"
inManagedObjectContext:self.managedObjectContext];
- richcollins 15y agoThank you for further solidifying my point.