mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-12-04 03:44:58 +00:00
Merge branch 'master' of github.com:280north/cappuccino
This commit is contained in:
commit
b9ca57a921
8 files changed
+210
-70
No files matched your search
@@ -178,7 +178,7 @@ var CPBindingOperationAnd = 0,
|
||||
|
||||
[_source setValue:newValue forKey:aBinding];
|
||||
|
||||
if ([_source respondsToSelector:@selector(_setCurrentValueIsPlaceholder:)])
|
||||
if (aBinding === @"objectValue" && [_source respondsToSelector:@selector(_setCurrentValueIsPlaceholder:)])
|
||||
[_source _setCurrentValueIsPlaceholder:isPlaceholder];
|
||||
}
|
||||
|
||||
|
||||
+61
-37
@@ -275,7 +275,7 @@ var CPObjectControllerContentKey = @"CPObjectControllerCo
|
||||
|
||||
- (id)initWithKeyPath:(id)aKeyPath observer:(id)anObserver object:(id)anObject
|
||||
{
|
||||
if (self=[super init])
|
||||
if (self = [super init])
|
||||
{
|
||||
_keyPath = aKeyPath;
|
||||
_observer = anObserver;
|
||||
@@ -324,9 +324,9 @@ var CPObjectControllerContentKey = @"CPObjectControllerCo
|
||||
- (void)observeValueForKeyPath:(CPString)aKeyPath ofObject:(id)anObject change:(CPDictionary)change context:(id)context
|
||||
{
|
||||
if (_notifyObject)
|
||||
[_object observeValueForKeyPath:_keyPath ofObject:_object change:change context:context];
|
||||
[_object observeValueForKeyPath:aKeyPath ofObject:_object change:change context:context];
|
||||
|
||||
[_observer observeValueForKeyPath:_keyPath ofObject:_object change:change context:context];
|
||||
[_observer observeValueForKeyPath:aKeyPath ofObject:_object change:change context:context];
|
||||
}
|
||||
|
||||
- (CPString)description
|
||||
@@ -380,7 +380,7 @@ var CPObjectControllerContentKey = @"CPObjectControllerCo
|
||||
return self;
|
||||
}
|
||||
|
||||
-(void)addObserver:(id)anObserver forKeyPath:(CPString)aKeyPath options:(CPKeyValueObservingOptions)options context:(id)context
|
||||
- (void)addObserver:(id)anObserver forKeyPath:(CPString)aKeyPath options:(CPKeyValueObservingOptions)options context:(id)context
|
||||
{
|
||||
if (aKeyPath.indexOf("@") === 0)
|
||||
{
|
||||
@@ -392,7 +392,7 @@ var CPObjectControllerContentKey = @"CPObjectControllerCo
|
||||
[_observationProxies addObject:proxy];
|
||||
|
||||
var dotIndex = aKeyPath.indexOf("."),
|
||||
remaining = aKeyPath.substring(dotIndex+1),
|
||||
remaining = aKeyPath.substring(dotIndex + 1),
|
||||
indexes = [CPIndexSet indexSetWithIndexesInRange:CPMakeRange(0, [self count])];
|
||||
|
||||
[self addObserver:proxy toObjectsAtIndexes:indexes forKeyPath:remaining options:options context:context];
|
||||
@@ -414,7 +414,7 @@ var CPObjectControllerContentKey = @"CPObjectControllerCo
|
||||
proxy = [_observationProxies objectAtIndex:index];
|
||||
|
||||
var dotIndex = aKeyPath.indexOf("."),
|
||||
remaining = aKeyPath.substring(dotIndex+1),
|
||||
remaining = aKeyPath.substring(dotIndex + 1),
|
||||
indexes = [CPIndexSet indexSetWithIndexesInRange:CPMakeRange(0, [self count])];
|
||||
|
||||
[self removeObserver:proxy fromObjectsAtIndexes:indexes forKeyPath:remaining];
|
||||
@@ -428,7 +428,7 @@ var CPObjectControllerContentKey = @"CPObjectControllerCo
|
||||
|
||||
- (void)insertObject:(id)anObject atIndex:(unsigned)anIndex
|
||||
{
|
||||
for (var i=0, count=[_observationProxies count]; i<count; i++)
|
||||
for (var i = 0, count = [_observationProxies count]; i < count; i++)
|
||||
{
|
||||
var proxy = [_observationProxies objectAtIndex:i],
|
||||
keyPath = [proxy keyPath],
|
||||
@@ -448,7 +448,7 @@ var CPObjectControllerContentKey = @"CPObjectControllerCo
|
||||
|
||||
- (void)removeObjectAtIndex:(unsigned)anIndex
|
||||
{
|
||||
for (var i=0, count=[_observationProxies count]; i<count; i++)
|
||||
for (var i = 0, count = [_observationProxies count]; i < count; i++)
|
||||
{
|
||||
var proxy = [_observationProxies objectAtIndex:i],
|
||||
keyPath = [proxy keyPath],
|
||||
@@ -485,7 +485,7 @@ var CPObjectControllerContentKey = @"CPObjectControllerCo
|
||||
{
|
||||
var currentObject = [self objectAtIndex:anIndex];
|
||||
|
||||
for (var i=0, count=[_observationProxies count]; i<count; i++)
|
||||
for (var i = 0, count = [_observationProxies count]; i < count; i++)
|
||||
{
|
||||
var proxy = [_observationProxies objectAtIndex:i],
|
||||
keyPath = [proxy keyPath],
|
||||
@@ -508,11 +508,13 @@ var CPObjectControllerContentKey = @"CPObjectControllerCo
|
||||
|
||||
@implementation CPControllerSelectionProxy : CPObject
|
||||
{
|
||||
id _controller;
|
||||
id _keys;
|
||||
id _controller;
|
||||
id _keys;
|
||||
|
||||
CPDictionary _cachedValues;
|
||||
CPArray _observationProxies;
|
||||
CPDictionary _cachedValues;
|
||||
CPArray _observationProxies;
|
||||
|
||||
Object _observedObjectsByKeyPath;
|
||||
}
|
||||
|
||||
- (id)initWithController:(id)aController
|
||||
@@ -522,46 +524,65 @@ var CPObjectControllerContentKey = @"CPObjectControllerCo
|
||||
_cachedValues = [CPDictionary dictionary];
|
||||
_observationProxies = [CPArray array];
|
||||
_controller = aController;
|
||||
_observedObjectsByKeyPath = {};
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id)valueForKey:(CPString)aKey
|
||||
- (id)_controllerMarkerForValues:(CPArray)theValues
|
||||
{
|
||||
var value = [_cachedValues objectForKey:aKey];
|
||||
|
||||
if (value !== undefined && value !== nil)
|
||||
return value;
|
||||
|
||||
var allValues = [[_controller selectedObjects] valueForKeyPath:aKey],
|
||||
count = [allValues count];
|
||||
var count = [theValues count];
|
||||
|
||||
if (!count)
|
||||
value = CPNoSelectionMarker;
|
||||
else if (count === 1)
|
||||
value = [allValues objectAtIndex:0];
|
||||
value = [theValues objectAtIndex:0];
|
||||
else
|
||||
{
|
||||
if ([_controller alwaysUsesMultipleValuesMarker])
|
||||
value = CPMultipleValuesMarker;
|
||||
else
|
||||
{
|
||||
value = [allValues objectAtIndex:0];
|
||||
value = [theValues objectAtIndex:0];
|
||||
|
||||
for (var i=0, count=[allValues count]; i<count && value!=CPMultipleValuesMarker; i++)
|
||||
for (var i = 0, count= [theValues count]; i < count && value != CPMultipleValuesMarker; i++)
|
||||
{
|
||||
if (![value isEqual:[allValues objectAtIndex:i]])
|
||||
if (![value isEqual:[theValues objectAtIndex:i]])
|
||||
value = CPMultipleValuesMarker;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[_cachedValues setValue:value forKey:aKey];
|
||||
return value;
|
||||
}
|
||||
|
||||
- (id)valueForKeyPath:(CPString)theKeyPath
|
||||
{
|
||||
var values = [[_controller selectedObjects] valueForKeyPath:theKeyPath];
|
||||
value = [self _controllerMarkerForValues:values];
|
||||
|
||||
[_cachedValues setObject:value forKey:theKeyPath];
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
- (id)valueForKey:(CPString)theKeyPath
|
||||
{
|
||||
return [self valueForKeyPath:theKeyPath];
|
||||
}
|
||||
|
||||
- (void)setValue:(id)theValue forKeyPath:(CPString)theKeyPath
|
||||
{
|
||||
[[_controller selectedObjects] setValue:theValue forKeyPath:theKeyPath];
|
||||
[_cachedValues removeObjectForKey:theKeyPath];
|
||||
}
|
||||
|
||||
- (void)setValue:(id)theValue forKey:(CPString)theKeyPath
|
||||
{
|
||||
[self setValue:theKeyPath forKeyPath:theKeyPath];
|
||||
}
|
||||
|
||||
- (unsigned)count
|
||||
{
|
||||
return [_cachedValues count];
|
||||
@@ -572,32 +593,27 @@ var CPObjectControllerContentKey = @"CPObjectControllerCo
|
||||
return [_cachedValues keyEnumerator];
|
||||
}
|
||||
|
||||
- (void)setValue:(id)aValue forKey:(CPString)aKey
|
||||
{
|
||||
[[_controller selectedObjects] setValue:aValue forKey:aKey];
|
||||
}
|
||||
|
||||
-(void)controllerWillChange
|
||||
- (void)controllerWillChange
|
||||
{
|
||||
_keys = [_cachedValues allKeys];
|
||||
|
||||
if (!_keys)
|
||||
return;
|
||||
|
||||
for (var i=0, count=_keys.length; i<count; i++)
|
||||
for (var i = 0, count = _keys.length; i < count; i++)
|
||||
[self willChangeValueForKey:_keys[i]];
|
||||
|
||||
[_cachedValues removeAllObjects];
|
||||
}
|
||||
|
||||
-(void)controllerDidChange
|
||||
- (void)controllerDidChange
|
||||
{
|
||||
[_cachedValues removeAllObjects];
|
||||
|
||||
if (!_keys)
|
||||
return;
|
||||
|
||||
for (var i=0, count=_keys.length; i<count; i++)
|
||||
for (var i = 0, count = _keys.length; i < count; i++)
|
||||
[self didChangeValueForKey:_keys[i]];
|
||||
|
||||
_keys = nil;
|
||||
@@ -615,7 +631,11 @@ var CPObjectControllerContentKey = @"CPObjectControllerCo
|
||||
[proxy setNotifyObject:YES];
|
||||
[_observationProxies addObject:proxy];
|
||||
|
||||
[[_controller selectedObjects] addObserver:proxy forKeyPath:aKeyPath options:options context:context];
|
||||
// We keep are reference to the observed objects
|
||||
// because the removeObserver: will be called after the selection changes
|
||||
var observedObjects = [_controller selectedObjects];
|
||||
_observedObjectsByKeyPath[aKeyPath] = observedObjects;
|
||||
[observedObjects addObserver:proxy forKeyPath:aKeyPath options:options context:context];
|
||||
}
|
||||
|
||||
- (void)removeObserver:(id)anObject forKeyPath:(CPString)aKeyPath
|
||||
@@ -623,8 +643,12 @@ var CPObjectControllerContentKey = @"CPObjectControllerCo
|
||||
var proxy = [[_CPObservationProxy alloc] initWithKeyPath:aKeyPath observer:anObject object:self],
|
||||
index = [_observationProxies indexOfObject:proxy];
|
||||
|
||||
[[_controller selectedObjects] removeObserver:[_observationProxies objectAtIndex:index] forKeyPath:aKeyPath];
|
||||
var observedObjects = _observedObjectsByKeyPath[aKeyPath];
|
||||
[observedObjects removeObserver:[_observationProxies objectAtIndex:index] forKeyPath:aKeyPath];
|
||||
|
||||
[_observationProxies removeObjectAtIndex:index];
|
||||
|
||||
_observedObjects = nil;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -102,7 +102,7 @@
|
||||
|
||||
- (void)setFont:(CPFont)aFont
|
||||
{
|
||||
[_textField setFont:aFont];
|
||||
[self setValue:aFont forThemeAttribute:"text-font"];
|
||||
}
|
||||
|
||||
- (void)_setIndicatorImage:(CPImage)anImage
|
||||
|
||||
@@ -789,10 +789,6 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
|
||||
- (void)_setCurrentValueIsPlaceholder:(BOOL)isPlaceholder
|
||||
{
|
||||
// The initial _currentValueIsPlaceholder is null so convert it to NO for comparison purposes.
|
||||
if (!!_currentValueIsPlaceholder === isPlaceholder)
|
||||
return;
|
||||
|
||||
if (isPlaceholder)
|
||||
{
|
||||
// Save the original placeholder value so we can restore it later
|
||||
@@ -805,7 +801,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
[self setPlaceholderString:[self stringValue]];
|
||||
[self setStringValue:@""];
|
||||
}
|
||||
else
|
||||
else if (_originalPlaceholderString)
|
||||
{
|
||||
// Restore the original placeholder, the actual textfield value is already correct
|
||||
// because it was set using setValue:forKey:
|
||||
|
||||
@@ -210,17 +210,18 @@ var CPObjectAccessorsForClassKey = @"$CPObjectAccessorsForClassKey",
|
||||
|
||||
- (void)setValue:(id)aValue forKeyPath:(CPString)aKeyPath
|
||||
{
|
||||
if (!aKeyPath) aKeyPath = "self";
|
||||
if (!aKeyPath) aKeyPath = @"self";
|
||||
|
||||
var i = 0,
|
||||
keys = aKeyPath.split("."),
|
||||
count = keys.length - 1,
|
||||
owner = self;
|
||||
var firstDotIndex = aKeyPath.indexOf(".");
|
||||
|
||||
for (; i < count; ++i)
|
||||
owner = [owner valueForKey:keys[i]];
|
||||
if (firstDotIndex === -1)
|
||||
return [self setValue:aValue forKey:aKeyPath];
|
||||
|
||||
[owner setValue:aValue forKey:keys[i]];
|
||||
var firstKeyComponent = aKeyPath.substring(0, firstDotIndex),
|
||||
remainingKeyPath = aKeyPath.substring(firstDotIndex + 1),
|
||||
value = [self valueForKey:firstKeyComponent];
|
||||
|
||||
return [value setValue:aValue forKeyPath:remainingKeyPath];
|
||||
}
|
||||
|
||||
- (void)setValue:(id)aValue forKey:(CPString)aKey
|
||||
|
||||
@@ -13,9 +13,9 @@
|
||||
{
|
||||
_contentArray = [];
|
||||
|
||||
[_contentArray addObject:[Person personWithName:@"Francisco" age:21]];
|
||||
[_contentArray addObject:[Person personWithName:@"Ross" age:30]];
|
||||
[_contentArray addObject:[Person personWithName:@"Tom" age:15]];
|
||||
[_contentArray addObject:[Employee employeeWithName:@"Francisco" department:[Department departmentWithName:@"Cappuccino"]]];
|
||||
[_contentArray addObject:[Employee employeeWithName:@"Ross" department:[Department departmentWithName:@"Cappuccino"]]];
|
||||
[_contentArray addObject:[Employee employeeWithName:@"Tom" department:[Department departmentWithName:@"CommonJS"]]];
|
||||
|
||||
// Copy the array since we'll reuse the original array later. Also see issue #795.
|
||||
_arrayController = [[CPArrayController alloc] initWithContent:[[self contentArray] copy]];
|
||||
@@ -46,10 +46,10 @@
|
||||
|
||||
- (void)testInsertObjectAtArrangedObjectIndex
|
||||
{
|
||||
var object = [Person personWithName:@"Klaas Pieter" age:24],
|
||||
var object = [Employee employeeWithName:@"Klaas Pieter" department:[Department departmentWithName:@"Theming"]],
|
||||
arrayController = [self arrayController];
|
||||
|
||||
[arrayController setSortDescriptors:[[CPSortDescriptor sortDescriptorWithKey:@"age" ascending:YES]]];
|
||||
[arrayController setSortDescriptors:[[CPSortDescriptor sortDescriptorWithKey:@"name" ascending:YES]]];
|
||||
[arrayController insertObject:object atArrangedObjectIndex:1];
|
||||
|
||||
[self assert:object equals:[[arrayController arrangedObjects] objectAtIndex:1]];
|
||||
@@ -296,6 +296,40 @@
|
||||
[self assert:newSelection equals:[arrayController selectionIndexes] message:@"selection was not set properly"];
|
||||
}
|
||||
|
||||
- (void)testCompoundKeyPaths
|
||||
{
|
||||
var departmentNameField = [[CPTextField alloc] init];
|
||||
[departmentNameField bind:@"value" toObject:[self arrayController] withKeyPath:@"selection.department.name" options:nil];
|
||||
|
||||
// This should be 'No Selection'
|
||||
[self assert:@"" equals:[departmentNameField stringValue]];
|
||||
|
||||
[[self arrayController] setSelectionIndexes:[CPIndexSet indexSetWithIndex:1]];
|
||||
[self assert:@"Cappuccino" equals:[departmentNameField stringValue]];
|
||||
|
||||
[[self arrayController] setSelectionIndexes:[CPIndexSet indexSetWithIndexesInRange:CPMakeRange(0, 2)]];
|
||||
[self assert:@"Cappuccino" equals:[departmentNameField stringValue] message:@"key path values should be equal"];
|
||||
|
||||
[[self arrayController] setValue:@"280North" forKeyPath:@"selection.department.name"];
|
||||
[self assert:@"280North" equals:[departmentNameField stringValue]];
|
||||
|
||||
[[self arrayController] setSelectionIndexes:[CPIndexSet indexSetWithIndex:1]];
|
||||
|
||||
[[self arrayController] valueForKeyPath:@"selection.department.name"];
|
||||
[[self arrayController] valueForKeyPath:@"selection.department.building"];
|
||||
[[self arrayController] valueForKeyPath:@"selection.department"];
|
||||
|
||||
var employee = [[[self arrayController] selectedObjects] lastObject],
|
||||
department = [Department departmentWithName:@"Meh"];
|
||||
|
||||
[department setBuilding:@"Building 1"];
|
||||
[employee setDepartment:department];
|
||||
|
||||
[self assert:@"Meh" equals:[departmentNameField stringValue]];
|
||||
[self assert:department equals:[[self arrayController] valueForKeyPath:@"selection.department"]];
|
||||
[self assert:@"Building 1" equals:[[self arrayController] valueForKeyPath:@"selection.department.building"]];
|
||||
}
|
||||
|
||||
- (void)observeValueForKeyPath:keyPath
|
||||
ofObject:anActivity
|
||||
change:change
|
||||
@@ -313,23 +347,23 @@
|
||||
|
||||
@end
|
||||
|
||||
@implementation Person : CPObject
|
||||
@implementation Employee : CPObject
|
||||
{
|
||||
CPString _name @accessors(property=name);
|
||||
int _age @accessors(property=age);
|
||||
CPString _name @accessors(property=name);
|
||||
Department _department @accessors(property=department);
|
||||
}
|
||||
|
||||
+ (id)personWithName:(CPString)aName age:(int)anAge
|
||||
+ (id)employeeWithName:(CPString)theName department:(Department)theDepartment
|
||||
{
|
||||
return [[self alloc] initWithName:aName age:anAge];
|
||||
return [[self alloc] initWithName:theName department:theDepartment];
|
||||
}
|
||||
|
||||
- (id)initWithName:(CPString)aName age:(int)anAge
|
||||
- (id)initWithName:(CPString)theName department:(Department)theDepartment
|
||||
{
|
||||
if (self = [super init])
|
||||
{
|
||||
_name = aName;
|
||||
_age = anAge;
|
||||
_name = theName;
|
||||
_department = theDepartment;
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -337,7 +371,30 @@
|
||||
|
||||
- (CPString)description
|
||||
{
|
||||
return [CPString stringWithFormat:@"<Person %@ : %@>", [self name], [self age]];
|
||||
return [CPString stringWithFormat:@"<Employee %@>", [self name]];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation Department : CPObject
|
||||
{
|
||||
CPString _name @accessors(property=name);
|
||||
CPString _building @accessors(property=building);
|
||||
}
|
||||
|
||||
+ (id)departmentWithName:(CPString)theName
|
||||
{
|
||||
return [[self alloc] initWithName:theName];
|
||||
}
|
||||
|
||||
- (id)initWithName:(CPString)theName
|
||||
{
|
||||
if (self = [super init])
|
||||
{
|
||||
_name = theName;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -201,19 +201,26 @@
|
||||
|
||||
content = [
|
||||
[BindingTester testerWithCheese:@"yellow"],
|
||||
[BindingTester testerWithCheese:@"green"]
|
||||
[BindingTester testerWithCheese:@"green"],
|
||||
];
|
||||
arrayController = [[CPArrayController alloc] initWithContent:content];
|
||||
|
||||
[arrayController setSelectionIndexes:[CPIndexSet indexSetWithIndexesInRange:CPMakeRange(0, 2)]];
|
||||
[arrayController setSelectionIndex:0];
|
||||
|
||||
var options = [CPDictionary dictionaryWithJSObject:{CPMultipleValuesPlaceholderBindingOption:@"Multiple Values"}];
|
||||
[textField bind:@"value" toObject:arrayController withKeyPath:@"selection.cheese" options:options];
|
||||
|
||||
[self assert:@"Multiple Values" equals:[textField placeholderString]];
|
||||
[self assert:@"yellow" equals:[textField stringValue] message:@"text field string value should be 'yellow'"];
|
||||
[self assert:@"cheese" equals:[textField placeholderString] message:@"text field placeholder should be 'cheese'"];
|
||||
|
||||
[arrayController setSelectionIndexes:[CPIndexSet indexSetWithIndexesInRange:CPMakeRange(0, 2)]];
|
||||
|
||||
[self assert:@"" equals:[textField stringValue] message:@"text field string value should be cleared"];
|
||||
[self assert:@"Multiple Values" equals:[textField placeholderString] message:@"text field placeholder should be 'Multiple Values'"];
|
||||
|
||||
[arrayController setSelectionIndex:0];
|
||||
[self assert:@"cheese" equals:[textField placeholderString]];
|
||||
[self assert:@"yellow" equals:[textField stringValue] message:"text field string value should be 'yellow'"];
|
||||
[self assert:@"cheese" equals:[textField placeholderString] message:"text field placeholder should be restored"];
|
||||
}
|
||||
|
||||
- (void)observeValueForKeyPath:(CPString)aKeyPath ofObject:(id)anObject change:(CPDictionary)changes context:(id)aContext
|
||||
|
||||
@@ -30,4 +30,59 @@
|
||||
[self assert:[CPNull null] equals:[nullObject valueForKey:@"a"] message:@"CPNull valueForKey:X returns nil"];
|
||||
}
|
||||
|
||||
- (void)testValueForKeyPath
|
||||
{
|
||||
var department = [Department departmentWithName:@"Engineering"],
|
||||
employee = [Employee employeeWithName:@"Klaas Pieter" department:department];
|
||||
|
||||
[self assert:department equals:[employee valueForKey:@"department"]];
|
||||
[self assert:@"Engineering" equals:[employee valueForKeyPath:@"department.name"]];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation Employee : CPObject
|
||||
{
|
||||
CPString _name @accessors(property=name);
|
||||
Department _department @accessors(property=department);
|
||||
}
|
||||
|
||||
+ (id)employeeWithName:(CPString)theName department:(Department)theDepartment
|
||||
{
|
||||
return [[self alloc] initWithName:theName department:theDepartment];
|
||||
}
|
||||
|
||||
- (id)initWithName:(CPString)theName department:(Department)theDepartment
|
||||
{
|
||||
if (self = [super init])
|
||||
{
|
||||
_name = theName;
|
||||
_department = theDepartment;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation Department : CPObject
|
||||
{
|
||||
CPString _name @accessors(property=name);
|
||||
}
|
||||
|
||||
+ (id)departmentWithName:(CPString)theName
|
||||
{
|
||||
return [[self alloc] initWithName:theName];
|
||||
}
|
||||
|
||||
- (id)initWithName:(CPString)theName
|
||||
{
|
||||
if (self = [super init])
|
||||
{
|
||||
_name = theName;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in new issue
Block a user