Skip to content

Commit

Permalink
Implemented #ifdefs for OS_OBJECT_USE_OBJC
Browse files Browse the repository at this point in the history
from iOS 6 and OSX 10.8 GCD objects (like semaphores) use ARC, this compiler flag adjusts the code based on whether or not the current minimum OS supports it
  • Loading branch information
odrobnik committed Jan 18, 2013
1 parent 973507a commit d434cf1
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 7 deletions.
6 changes: 5 additions & 1 deletion Core/Source/DTAttributedTextContentView.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,11 @@

@property (nonatomic, assign) IBOutlet id <DTAttributedTextContentViewDelegate> delegate; // subtle simulator bug - use assign not __unsafe_unretained

@property (nonatomic, assign) dispatch_semaphore_t selfLock;
#if OS_OBJECT_USE_OBJC
@property (nonatomic, strong) dispatch_semaphore_t selfLock; // GCD objects use ARC
#else
@property (nonatomic, assign) dispatch_semaphore_t selfLock; // GCD objects don't use ARC
#endif


@end
Expand Down
4 changes: 3 additions & 1 deletion Core/Source/DTAttributedTextContentView.m
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,10 @@ - (void)awakeFromNib
- (void)dealloc
{
[self removeAllCustomViews];


#if !OS_OBJECT_USE_OBJC
dispatch_release(selfLock);
#endif
}

- (void)layoutSubviewsInRect:(CGRect)rect
Expand Down
9 changes: 8 additions & 1 deletion Core/Source/DTCoreTextGlyphRun.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,12 @@ @interface DTCoreTextGlyphRun ()
@property (nonatomic, assign) CGRect frame;
@property (nonatomic, assign) NSInteger numberOfGlyphs;
@property (nonatomic, unsafe_unretained, readwrite) NSDictionary *attributes;
@property (nonatomic, assign) dispatch_semaphore_t runLock;

#if OS_OBJECT_USE_OBJC
@property (nonatomic, strong) dispatch_semaphore_t runLock; // GCD objects use ARC
#else
@property (nonatomic, assign) dispatch_semaphore_t runLock; // GCD objects don't use ARC
#endif

@end

Expand Down Expand Up @@ -86,7 +91,9 @@ - (void)dealloc
CFRelease(_run);
}

#if !OS_OBJECT_USE_OBJC
dispatch_release(runLock);
#endif
}

- (NSString *)description
Expand Down
9 changes: 8 additions & 1 deletion Core/Source/DTCoreTextLayouter.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@
@interface DTCoreTextLayouter ()

@property (nonatomic, strong) NSMutableArray *frames;
@property (nonatomic, assign) dispatch_semaphore_t selfLock;

#if OS_OBJECT_USE_OBJC
@property (nonatomic, strong) dispatch_semaphore_t selfLock; // GCD objects use ARC
#else
@property (nonatomic, assign) dispatch_semaphore_t selfLock; // GCD objects don't use ARC
#endif

- (CTFramesetterRef)framesetter;
- (void)discardFramesetter;
Expand Down Expand Up @@ -53,7 +58,9 @@ - (void)dealloc
[self discardFramesetter];
SYNCHRONIZE_END(self)

#if !OS_OBJECT_USE_OBJC
dispatch_release(selfLock);
#endif
}

- (NSString *)description
Expand Down
4 changes: 1 addition & 3 deletions Core/Source/DTHTMLAttributedStringBuilder.m
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,12 @@ - (id)initWithHTML:(NSData *)data options:(NSDictionary *)options documentAttrib

- (void)dealloc
{
#if TARGET_API_MAC_OSX
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1080
#if !OS_OBJECT_USE_OBJC
dispatch_release(_stringAssemblyQueue);
dispatch_release(_stringAssemblyGroup);
dispatch_release(_stringParsingQueue);
dispatch_release(_stringParsingGroup);
#endif
#endif
}

- (BOOL)_buildString
Expand Down

1 comment on commit d434cf1

@a2
Copy link

@a2 a2 commented on d434cf1 Jan 18, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Glad I could help. 😄

Please sign in to comment.