Skip to content

Commit

Permalink
Merge pull request jverkoey#298 from yosit/master
Browse files Browse the repository at this point in the history
Added support for NI_WEAK & NI_STRONG
  • Loading branch information
jverkoey committed Oct 15, 2012
2 parents cb2f1f0 + 37e4acb commit 54a9cfd
Show file tree
Hide file tree
Showing 52 changed files with 190 additions and 155 deletions.
8 changes: 4 additions & 4 deletions src/attributedlabel/src/NIAttributedLabel.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ typedef enum {
- (void)addLink:(NSURL *)urlLink range:(NSRange)range;
- (void)removeAllExplicitLinks; // Removes all links that were added by addLink:range:. Does not remove autodetected links.

@property (nonatomic, strong) UIColor* linkColor; // Default: [UIColor blueColor]
@property (nonatomic, strong) UIColor* highlightedLinkBackgroundColor; // Default: [UIColor colorWithWhite:0.5 alpha:0.5
@property (nonatomic, NI_STRONG) UIColor* linkColor; // Default: [UIColor blueColor]
@property (nonatomic, NI_STRONG) UIColor* highlightedLinkBackgroundColor; // Default: [UIColor colorWithWhite:0.5 alpha:0.5
@property (nonatomic, assign) BOOL linksHaveUnderlines; // Default: NO
@property (nonatomic, copy) NSDictionary *attributesForLinks; // Default: nil
@property (nonatomic, copy) NSDictionary *attributesForHighlightedLink; // Default: nil
Expand All @@ -95,7 +95,7 @@ typedef enum {
@property (nonatomic, assign) CTUnderlineStyleModifiers underlineStyleModifier;
@property (nonatomic, assign) CGFloat shadowBlur; // Default: 0
@property (nonatomic, assign) CGFloat strokeWidth;
@property (nonatomic, strong) UIColor* strokeColor;
@property (nonatomic, NI_STRONG) UIColor* strokeColor;
@property (nonatomic, assign) CGFloat textKern;

- (void)setTextColor:(UIColor *)textColor range:(NSRange)range;
Expand All @@ -109,7 +109,7 @@ typedef enum {
- (void)insertImage:(UIImage *)image atIndex:(NSInteger)index margins:(UIEdgeInsets)margins;
- (void)insertImage:(UIImage *)image atIndex:(NSInteger)index margins:(UIEdgeInsets)margins verticalTextAlignment:(NIVerticalTextAlignment)verticalTextAlignment;

@property (nonatomic, assign) IBOutlet id<NIAttributedLabelDelegate> delegate;
@property (nonatomic, NI_WEAK) IBOutlet id<NIAttributedLabelDelegate> delegate;
@end

/**
Expand Down
20 changes: 10 additions & 10 deletions src/attributedlabel/src/NIAttributedLabel.m
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ CGSize NISizeOfAttributedStringConstrainedToSize(NSAttributedString *attributedS

@interface NIAttributedLabelImage : NSObject
@property (nonatomic, assign) NSInteger index;
@property (nonatomic, strong) UIImage* image;
@property (nonatomic, NI_STRONG) UIImage* image;
@property (nonatomic, assign) UIEdgeInsets margins;
@property (nonatomic, assign) NIVerticalTextAlignment verticalTextAlignment;
@property (nonatomic, weak) NIAttributedLabel* label;
@property (nonatomic, NI_WEAK) NIAttributedLabel* label;
@end

@implementation NIAttributedLabelImage
Expand All @@ -91,19 +91,19 @@ @implementation NIAttributedLabelImage


@interface NIAttributedLabel() <UIActionSheetDelegate>
@property (nonatomic, strong) NSMutableAttributedString* mutableAttributedString;
@property (nonatomic, NI_STRONG) NSMutableAttributedString* mutableAttributedString;
@property (nonatomic, assign) CTFrameRef textFrame;
@property (assign) BOOL detectingLinks; // Atomic.
@property (nonatomic, assign) BOOL linksHaveBeenDetected;
@property (nonatomic, copy) NSArray* detectedlinkLocations;
@property (nonatomic, strong) NSMutableArray* explicitLinkLocations;
@property (nonatomic, strong) NSTextCheckingResult* originalLink;
@property (nonatomic, strong) NSTextCheckingResult* touchedLink;
@property (nonatomic, strong) NSTimer* longPressTimer;
@property (nonatomic, NI_STRONG) NSMutableArray* explicitLinkLocations;
@property (nonatomic, NI_STRONG) NSTextCheckingResult* originalLink;
@property (nonatomic, NI_STRONG) NSTextCheckingResult* touchedLink;
@property (nonatomic, NI_STRONG) NSTimer* longPressTimer;
@property (nonatomic, assign) CGPoint touchPoint;
@property (nonatomic, strong) NSTextCheckingResult* actionSheetLink;
@property (nonatomic, strong) NSArray *accessibleElements;
@property (nonatomic, strong) NSMutableArray *images;
@property (nonatomic, NI_STRONG) NSTextCheckingResult* actionSheetLink;
@property (nonatomic, NI_STRONG) NSArray *accessibleElements;
@property (nonatomic, NI_STRONG) NSMutableArray *images;
@end


Expand Down
10 changes: 6 additions & 4 deletions src/badge/src/NIBadgeView.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

#import <UIKit/UIKit.h>

#import "NIPreprocessorMacros.h" /* for NI_WEAK */

/**
* A view that mimics the iOS notification badge style.
*
Expand All @@ -32,12 +34,12 @@

// Text attributes
@property (nonatomic, readwrite, copy) NSString* text;
@property (nonatomic, readwrite, retain) UIFont* font;
@property (nonatomic, readwrite, retain) UIColor* textColor;
@property (nonatomic, readwrite, NI_STRONG) UIFont* font;
@property (nonatomic, readwrite, NI_STRONG) UIColor* textColor;

// Badge attributes
@property (nonatomic, readwrite, retain) UIColor* tintColor;
@property (nonatomic, readwrite, retain) UIColor* shadowColor;
@property (nonatomic, readwrite, NI_STRONG) UIColor* tintColor;
@property (nonatomic, readwrite, NI_STRONG) UIColor* shadowColor;
@property (nonatomic, readwrite, assign) CGSize shadowOffset;
@property (nonatomic, readwrite, assign) CGFloat shadowBlur;

Expand Down
10 changes: 5 additions & 5 deletions src/core/src/NIDataStructures.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@

// The internal representation of a single node.
@interface NILinkedListNode : NSObject
@property (nonatomic, readwrite, retain) id object;
@property (nonatomic, readwrite, retain) NILinkedListNode* prev;
@property (nonatomic, readwrite, retain) NILinkedListNode* next;
@property (nonatomic, readwrite, NI_STRONG) id object;
@property (nonatomic, readwrite, NI_STRONG) NILinkedListNode* prev;
@property (nonatomic, readwrite, NI_STRONG) NILinkedListNode* next;
@end

@implementation NILinkedListNode
Expand Down Expand Up @@ -61,8 +61,8 @@ - (BOOL)isEqual:(id)object {

@interface NILinkedList()
// Exposed so that the linked list enumerator can iterate over the nodes directly.
@property (nonatomic, readonly, retain) NILinkedListNode* head;
@property (nonatomic, readonly, retain) NILinkedListNode* tail;
@property (nonatomic, readonly, NI_STRONG) NILinkedListNode* head;
@property (nonatomic, readonly, NI_STRONG) NILinkedListNode* tail;
@property (nonatomic, readwrite, assign) NSUInteger count;
@property (nonatomic, readwrite, assign) unsigned long modificationNumber;
@end
Expand Down
12 changes: 6 additions & 6 deletions src/core/src/NIInMemoryCache.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@

@interface NIMemoryCache()
// Mapping from a name (usually a URL) to an internal object.
@property (nonatomic, readwrite, retain) NSMutableDictionary* cacheMap;
@property (nonatomic, readwrite, NI_STRONG) NSMutableDictionary* cacheMap;
// A linked list of least recently used cache objects. Most recently used is the tail.
@property (nonatomic, readwrite, retain) NILinkedList* lruCacheObjects;
@property (nonatomic, readwrite, NI_STRONG) NILinkedList* lruCacheObjects;
@end


Expand All @@ -49,12 +49,12 @@ @interface NIMemoryCacheInfo : NSObject
/**
* @brief The object stored in the cache.
*/
@property (nonatomic, readwrite, retain) id object;
@property (nonatomic, readwrite, NI_STRONG) id object;

/**
* @brief The date after which the image is no longer valid and should be removed from the cache.
*/
@property (nonatomic, readwrite, retain) NSDate* expirationDate;
@property (nonatomic, readwrite, NI_STRONG) NSDate* expirationDate;

/**
* @brief The last time this image was accessed.
Expand All @@ -64,12 +64,12 @@ @interface NIMemoryCacheInfo : NSObject
* images. When the memory limit is reached, we sort the cache based on the last access times and
* then prune images until we're under the memory limit again.
*/
@property (nonatomic, readwrite, retain) NSDate* lastAccessTime;
@property (nonatomic, readwrite, NI_STRONG) NSDate* lastAccessTime;

/**
* @brief The location of this object in the least-recently used linked list.
*/
@property (nonatomic, readwrite, retain) NILinkedListLocation* lruLocation;
@property (nonatomic, readwrite, NI_STRONG) NILinkedListLocation* lruLocation;

/**
* @brief Determine whether this cache entry has past its expiration date.
Expand Down
8 changes: 5 additions & 3 deletions src/core/src/NINavigationAppearance.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#import "NIDebuggingTools.h"
#import "NISDKAvailability.h"

#import "NIPreprocessorMacros.h" /* for NI_WEAK */

#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "Nimbus requires ARC support."
#endif
Expand Down Expand Up @@ -60,17 +62,17 @@ @interface NINavigationAppearanceSnapshot : NSObject {
/**
* Holds value of UINavigationBar's tintColor property.
*/
@property (nonatomic, readonly, strong) UIColor* navBarTintColor;
@property (nonatomic, readonly, NI_STRONG) UIColor* navBarTintColor;

/**
* Holds value of UINavigationBar's UIBarMetricsDefault backgroundImage property.
*/
@property (nonatomic, readonly, strong) UIImage* navBarDefaultImage;
@property (nonatomic, readonly, NI_STRONG) UIImage* navBarDefaultImage;

/**
* Holds value of UINavigationBar's UIBarMetricsLandscapePhone backgroundImage property.
*/
@property (nonatomic, readonly, strong) UIImage* navBarLandscapePhoneImage;
@property (nonatomic, readonly, NI_STRONG) UIImage* navBarLandscapePhoneImage;

/**
* Create a new snapshot.
Expand Down
2 changes: 1 addition & 1 deletion src/core/src/NIOperations+Subclassing.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
//

@interface NIOperation()
@property (readwrite, retain) NSError* lastError;
@property (readwrite, NI_STRONG) NSError* lastError;
@end
6 changes: 4 additions & 2 deletions src/core/src/NIOperations.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

#import "NIPreprocessorMacros.h" /* for NI_WEAK */

@class NIOperation;

typedef void (^NIOperationBlock)(NIOperation* operation);
Expand Down Expand Up @@ -48,8 +50,8 @@ typedef void (^NIOperationDidFailBlock)(NIOperation* operation, NSError* error);
*/
@interface NIOperation : NSOperation

@property (readwrite, weak) id<NIOperationDelegate> delegate;
@property (readonly, retain) NSError* lastError;
@property (readwrite, NI_WEAK) id<NIOperationDelegate> delegate;
@property (readonly, NI_STRONG) NSError* lastError;
@property (readwrite, assign) NSInteger tag;

@property (readwrite, copy) NIOperationBlock didStartBlock;
Expand Down
17 changes: 17 additions & 0 deletions src/core/src/NIPreprocessorMacros.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,23 @@ NI_FIX_CATEGORY_BUG(UIViewController_MyCustomCategory);
*/
#define RGBACOLOR(r,g,b,a) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:(a)]

/**
* A helper macro to keep the interfaces compatiable with pre ARC compilers.
* Useful when you put nimbus in a library and link it to a GCC LLVM compiler.
*/

#if defined(__has_feature) && __has_feature(objc_arc_weak)
#define NI_WEAK weak
#define NI_STRONG strong
#elif defined(__has_feature) && __has_feature(objc_arc)
#define NI_WEAK __unsafe_unretained
#define NI_STRONG retain
#else
#define NI_WEAK assign
#define NI_STRONG retain
#endif


///////////////////////////////////////////////////////////////////////////////////////////////////
/**@}*/// End of Preprocessor Macros //////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
4 changes: 3 additions & 1 deletion src/core/src/NISnapshotRotation.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

#import "NIPreprocessorMacros.h" /* for NI_WEAK */

/**
* An object designed to easily implement snapshot rotation.
*
Expand Down Expand Up @@ -48,7 +50,7 @@
// Designated initializer.
- (id)initWithDelegate:(id<NISnapshotRotationDelegate>)delegate;

@property (nonatomic, readwrite, weak) id<NISnapshotRotationDelegate> delegate;
@property (nonatomic, readwrite, NI_WEAK) id<NISnapshotRotationDelegate> delegate;

@property (nonatomic, readonly, assign) CGRect frameBeforeRotation;
@property (nonatomic, readonly, assign) CGRect frameAfterRotation;
Expand Down
6 changes: 3 additions & 3 deletions src/core/src/NISnapshotRotation.m
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ @interface NISnapshotRotation()
@property (nonatomic, readwrite, assign) CGRect frameBeforeRotation;
@property (nonatomic, readwrite, assign) CGRect frameAfterRotation;

@property (nonatomic, readwrite, retain) UIImageView* snapshotViewBeforeRotation;
@property (nonatomic, readwrite, retain) UIImageView* snapshotViewAfterRotation;
@property (nonatomic, readwrite, NI_STRONG) UIImageView* snapshotViewBeforeRotation;
@property (nonatomic, readwrite, NI_STRONG) UIImageView* snapshotViewAfterRotation;
@end


Expand Down Expand Up @@ -212,7 +212,7 @@ - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceO


@interface NITableViewSnapshotRotation() <NISnapshotRotationDelegate>
@property (nonatomic, readwrite, weak) id<NISnapshotRotationDelegate> forwardingDelegate;
@property (nonatomic, readwrite, NI_WEAK) id<NISnapshotRotationDelegate> forwardingDelegate;
@end


Expand Down
2 changes: 1 addition & 1 deletion src/core/src/NIViewRecycler.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#endif

@interface NIViewRecycler()
@property (nonatomic, readwrite, retain) NSMutableDictionary* reuseIdentifiersToRecycledViews;
@property (nonatomic, readwrite, NI_STRONG) NSMutableDictionary* reuseIdentifiersToRecycledViews;
@end


Expand Down
1 change: 1 addition & 0 deletions src/css/src/NIDOM.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

@class NIStylesheet;

Expand Down
2 changes: 1 addition & 1 deletion src/launcher/src/NILauncherButtonView.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
*/
@interface NILauncherButtonView : NIRecyclableView <NILauncherButtonView, NILauncherViewObjectView>

@property (nonatomic, readwrite, retain) UIButton* button;
@property (nonatomic, readwrite, NI_STRONG) UIButton* button;
@property (nonatomic, readwrite, copy) UILabel* label;

@property (nonatomic, readwrite, assign) UIEdgeInsets contentInset;
Expand Down
4 changes: 2 additions & 2 deletions src/launcher/src/NILauncherPageView.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
*/
@interface NILauncherPageView : NIPageView

@property (nonatomic, readwrite, retain) NIViewRecycler* viewRecycler;
@property (nonatomic, readwrite, NI_STRONG) NIViewRecycler* viewRecycler;

- (void)addRecyclableView:(UIView<NIRecyclableView> *)view;
@property (nonatomic, readonly, retain) NSArray* recyclableViews;
@property (nonatomic, readonly, NI_STRONG) NSArray* recyclableViews;

@property (nonatomic, readwrite, assign) UIEdgeInsets contentInset;
@property (nonatomic, readwrite, assign) CGSize viewSize;
Expand Down
2 changes: 1 addition & 1 deletion src/launcher/src/NILauncherPageView.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#endif

@interface NILauncherPageView()
@property (nonatomic, readwrite, retain) NSMutableArray* mutableRecyclableViews;
@property (nonatomic, readwrite, NI_STRONG) NSMutableArray* mutableRecyclableViews;
@end

///////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
6 changes: 3 additions & 3 deletions src/launcher/src/NILauncherView.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ extern const NSInteger NILauncherViewGridBasedOnButtonSize;
@property (nonatomic, readwrite, assign) NSInteger numberOfColumns; // Default: NILauncherViewGridBasedOnButtonSize

- (void)reloadData;
@property (nonatomic, readwrite, assign) id<NILauncherDelegate> delegate;
@property (nonatomic, readwrite, assign) id<NILauncherDataSource> dataSource;
@property (nonatomic, readwrite, NI_WEAK) id<NILauncherDelegate> delegate;
@property (nonatomic, readwrite, NI_WEAK) id<NILauncherDataSource> dataSource;

- (UIView<NILauncherButtonView> *)dequeueReusableViewWithIdentifier:(NSString *)identifier;

Expand Down Expand Up @@ -160,7 +160,7 @@ extern const NSInteger NILauncherViewGridBasedOnButtonSize;
/**
* Requires the view to contain a button subview.
*/
@property (nonatomic, readwrite, retain) UIButton* button;
@property (nonatomic, readwrite, NI_STRONG) UIButton* button;

@end

Expand Down
6 changes: 3 additions & 3 deletions src/launcher/src/NILauncherView.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@

///////////////////////////////////////////////////////////////////////////////////////////////////
@interface NILauncherView() <NIPagingScrollViewDataSource, NIPagingScrollViewDelegate>
@property (nonatomic, readwrite, retain) NIPagingScrollView* pagingScrollView;
@property (nonatomic, readwrite, retain) UIPageControl* pager;
@property (nonatomic, readwrite, NI_STRONG) NIPagingScrollView* pagingScrollView;
@property (nonatomic, readwrite, NI_STRONG) UIPageControl* pager;
@property (nonatomic, readwrite, assign) NSInteger numberOfPages;
@property (nonatomic, readwrite, retain) NIViewRecycler* viewRecycler;
@property (nonatomic, readwrite, NI_STRONG) NIViewRecycler* viewRecycler;
- (void)updateLayoutForPage:(NILauncherPageView *)page;
@end

Expand Down
2 changes: 1 addition & 1 deletion src/launcher/src/NILauncherViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
*/
@interface NILauncherViewController : UIViewController <NILauncherDelegate, NILauncherDataSource>

@property (nonatomic, readwrite, retain) NILauncherView* launcherView;
@property (nonatomic, readwrite, NI_STRONG) NILauncherView* launcherView;

@end

Expand Down
4 changes: 2 additions & 2 deletions src/launcher/src/NILauncherViewModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

- (id<NILauncherViewObject>)objectAtIndex:(NSInteger)index pageIndex:(NSInteger)pageIndex;

@property (nonatomic, readwrite, assign) id<NILauncherViewModelDelegate> delegate;
@property (nonatomic, readwrite, NI_WEAK) id<NILauncherViewModelDelegate> delegate;

@end

Expand Down Expand Up @@ -89,7 +89,7 @@
/**
* The image that will be displayed on the launcher view button.
*/
@property (nonatomic, readwrite, retain) UIImage* image;
@property (nonatomic, readwrite, NI_STRONG) UIImage* image;

/**
* The class of button view that should be used to display this object.
Expand Down
2 changes: 1 addition & 1 deletion src/launcher/src/NILauncherViewModel.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#endif

@interface NILauncherViewModel()
@property (nonatomic, readwrite, retain) NSMutableArray* pages;
@property (nonatomic, readwrite, NI_STRONG) NSMutableArray* pages;
@end

///////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
Loading

0 comments on commit 54a9cfd

Please sign in to comment.