Commit 0450faad authored by Pierre d'Herbemont's avatar Pierre d'Herbemont

MacOSX/Framework/VLCTime: Code cleanup and use Objective-C 2.0 @property. (Patch by Enrique Osuna).

parent a5015dec
...@@ -24,19 +24,27 @@ ...@@ -24,19 +24,27 @@
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
/**
* Provides an object to define VLCMedia's ti me.
*/
@interface VLCTime : NSObject @interface VLCTime : NSObject
{ {
NSNumber *value; NSNumber * value; //< Holds, in seconds, the VLCTime value
} }
/* Factories */
+ (VLCTime *)nullTime; + (VLCTime *)nullTime;
+ (VLCTime *)timeWithNumber:(NSNumber *)aNumber; + (VLCTime *)timeWithNumber:(NSNumber *)aNumber;
//+ (VLCTime *)timeWithString:(NSString *)aString; //+ (VLCTime *)timeWithString:(NSString *)aString;
/* Initializers */
- (id)initWithNumber:(NSNumber *)aNumber; - (id)initWithNumber:(NSNumber *)aNumber;
//- (id)initWithString:(NSString *)aString; //- (id)initWithString:(NSString *)aString;
- (NSNumber *)numberValue; /* Properties */
- (NSString *)stringValue; @property (readonly) NSNumber * numberValue;
@property (readonly) NSString * stringValue;
/* Comparitors */
- (NSComparisonResult)compare:(VLCTime *)aTime; - (NSComparisonResult)compare:(VLCTime *)aTime;
@end @end
...@@ -24,11 +24,10 @@ ...@@ -24,11 +24,10 @@
#import <VLCTime.h> #import <VLCTime.h>
static VLCTime *nullTime = nil;
@implementation VLCTime @implementation VLCTime
+ (VLCTime *)nullTime + (VLCTime *)nullTime
{ {
static VLCTime * nullTime = nil;
if (!nullTime) if (!nullTime)
nullTime = [[VLCTime timeWithNumber:nil] retain]; nullTime = [[VLCTime timeWithNumber:nil] retain];
return nullTime; return nullTime;
...@@ -76,7 +75,7 @@ static VLCTime *nullTime = nil; ...@@ -76,7 +75,7 @@ static VLCTime *nullTime = nil;
- (NSNumber *)numberValue - (NSNumber *)numberValue
{ {
return value ? [value copy] : nil; return value ? [[value copy] autorelease] : nil;
} }
- (NSString *)stringValue - (NSString *)stringValue
...@@ -103,11 +102,11 @@ static VLCTime *nullTime = nil; ...@@ -103,11 +102,11 @@ static VLCTime *nullTime = nil;
else if (!aTime) else if (!aTime)
return NSOrderedDescending; return NSOrderedDescending;
else else
return [value compare:[aTime numberValue]]; return [value compare:aTime.numberValue];
} }
- (NSString *)description - (NSString *)description
{ {
return [self stringValue]; return self.stringValue;
} }
@end @end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment