Skip to content

Commit

Permalink
Switched to 6.1 and modern Objective-C.
Browse files Browse the repository at this point in the history
  • Loading branch information
chbeer committed Jun 20, 2014
1 parent 5debf05 commit abf35a6
Show file tree
Hide file tree
Showing 45 changed files with 208 additions and 203 deletions.
6 changes: 4 additions & 2 deletions CBUIKit.xcodeproj/project.pbxproj
Expand Up @@ -574,12 +574,13 @@
1DEB922308733DC00010E9CD /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_OBJC_ARC = YES;
GCC_C_LANGUAGE_STANDARD = c99;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_VERSION = "";
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 5.0;
IPHONEOS_DEPLOYMENT_TARGET = 6.1;
ONLY_ACTIVE_ARCH = YES;
OTHER_LDFLAGS = "-ObjC";
SDKROOT = iphoneos;
Expand All @@ -589,11 +590,12 @@
1DEB922408733DC00010E9CD /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_OBJC_ARC = YES;
GCC_C_LANGUAGE_STANDARD = c99;
GCC_VERSION = "";
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 5.0;
IPHONEOS_DEPLOYMENT_TARGET = 6.1;
OTHER_LDFLAGS = "-ObjC";
SDKROOT = iphoneos;
};
Expand Down
8 changes: 4 additions & 4 deletions Classes/CBUIActionSheetController.h
Expand Up @@ -27,15 +27,15 @@ typedef void(^CBUIActionSheetHandler)(UIActionSheet *actionSheet, NSUInteger but

@property (nonatomic, assign) UIActionSheetStyle actionSheetStyle;

+ (id) actionSheetControllerWithTitle:(NSString*)title buttonsWithHandlerAndTitle:(CBUIActionSheetHandler)firstHandler, ...;
+ (id) actionSheetControllerWithTitle:(NSString*)title;
+ (instancetype) actionSheetControllerWithTitle:(NSString*)title buttonsWithHandlerAndTitle:(CBUIActionSheetHandler)firstHandler, ...;
+ (instancetype) actionSheetControllerWithTitle:(NSString*)title;

- (id) applyCancelButtonTitle:(NSString*)title handler:(CBUIActionSheetHandler)handler;
- (id) applyDestructiveButtonTitle:(NSString*)title handler:(CBUIActionSheetHandler)handler;
- (id) applyButtonWithTitle:(NSString*)title handler:(CBUIActionSheetHandler)handler;

- (id) initWithTitle:(NSString*)inTitle;
- (id) initWithTitle:(NSString*)inTitle buttonsWithHandlerAndTitle:(CBUIActionSheetHandler)firstHandler, ...;
- (instancetype) initWithTitle:(NSString*)inTitle NS_DESIGNATED_INITIALIZER;
- (instancetype) initWithTitle:(NSString*)inTitle buttonsWithHandlerAndTitle:(CBUIActionSheetHandler)firstHandler, ...;

- (void) setCancelButtonTitle:(NSString*)title handler:(CBUIActionSheetHandler)handler;
- (void) setDestructiveButtonTitle:(NSString*)title handler:(CBUIActionSheetHandler)handler;
Expand Down
10 changes: 5 additions & 5 deletions Classes/CBUIActionSheetController.m
Expand Up @@ -24,7 +24,7 @@ @implementation CBUIActionSheetController

@synthesize actionSheetStyle;

- (id) initWithTitle:(NSString*)inTitle
- (instancetype) initWithTitle:(NSString*)inTitle
{
self = [super init];
if (!self) return nil;
Expand All @@ -36,7 +36,7 @@ - (id) initWithTitle:(NSString*)inTitle
return self;
}

- (id) initWithTitle:(NSString*)inTitle buttonsWithHandlerAndTitle:(CBUIActionSheetHandler)firstHandler, ...
- (instancetype) initWithTitle:(NSString*)inTitle buttonsWithHandlerAndTitle:(CBUIActionSheetHandler)firstHandler, ...
{
self = [self initWithTitle:inTitle];
if (!self) return nil;
Expand All @@ -60,7 +60,7 @@ - (id) initWithTitle:(NSString*)inTitle buttonsWithHandlerAndTitle:(CBUIActionSh
return self;
}

+ (id) actionSheetControllerWithTitle:(NSString*)title buttonsWithHandlerAndTitle:(CBUIActionSheetHandler)firstHandler, ...
+ (instancetype) actionSheetControllerWithTitle:(NSString*)title buttonsWithHandlerAndTitle:(CBUIActionSheetHandler)firstHandler, ...
{
CBUIActionSheetController *ctrl = [[self alloc] initWithTitle:title];

Expand All @@ -82,7 +82,7 @@ + (id) actionSheetControllerWithTitle:(NSString*)title buttonsWithHandlerAndTitl

return ctrl;
}
+ (id) actionSheetControllerWithTitle:(NSString*)title
+ (instancetype) actionSheetControllerWithTitle:(NSString*)title
{
CBUIActionSheetController *ctrl = [[self alloc] initWithTitle:title];
return ctrl;
Expand Down Expand Up @@ -194,7 +194,7 @@ - (void)actionSheet:(UIActionSheet *)inActionSheet clickedButtonAtIndex:(NSInteg
if (inActionSheet.destructiveButtonIndex != -1) {
index--;
}
CBUIActionSheetControllerButton *button = [buttons objectAtIndex:index];
CBUIActionSheetControllerButton *button = buttons[index];
if (button.handler) {
button.handler(inActionSheet, index);
}
Expand Down
4 changes: 2 additions & 2 deletions Classes/CBUIActivityView.m
Expand Up @@ -36,7 +36,7 @@ + (id) sharedInstance
return sharedInstance;
}

- (id)init
- (instancetype)init
{
UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow];
CGFloat width = CBIsIPad() ? 180 : 160;
Expand Down Expand Up @@ -330,7 +330,7 @@ - (void) keyboardDidShowNotification:(NSNotification*)note

NSDictionary* info = [note userInfo];

CGRect kbRect = [[info objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue];
CGRect kbRect = [info[UIKeyboardFrameBeginUserInfoKey] CGRectValue];
CGSize kbSize = kbRect.size;

CGSize windowSize = keyWindow.bounds.size;
Expand Down
4 changes: 2 additions & 2 deletions Classes/CBUIAlertViewController.h
Expand Up @@ -29,8 +29,8 @@ typedef void(^CBUIAlertViewHandler)(UIAlertView *alertView, NSUInteger buttonInd
+ (id) alertWithTitle:(NSString*)title message:(NSString*)message;
+ (id) alertWithMessage:(NSString*)message;

- (id) initWithTitle:(NSString*)inTitle message:(NSString*)inMessage;
- (id) initWithTitle:(NSString*)inTitle message:(NSString*)inMessage buttonsWithHandlerAndTitle:(id)firstHandler, ...;
- (instancetype) initWithTitle:(NSString*)inTitle message:(NSString*)inMessage NS_DESIGNATED_INITIALIZER;
- (instancetype) initWithTitle:(NSString*)inTitle message:(NSString*)inMessage buttonsWithHandlerAndTitle:(id)firstHandler, ...;

- (void) setCancelButtonTitle:(NSString*)title handler:(CBUIAlertViewHandler)handler;
- (void) addButtonWithTitle:(NSString*)title handler:(CBUIAlertViewHandler)handler;
Expand Down
6 changes: 3 additions & 3 deletions Classes/CBUIAlertViewController.m
Expand Up @@ -24,7 +24,7 @@ @implementation CBUIAlertViewController

@synthesize alertViewStyle;

- (id) initWithTitle:(NSString*)inTitle message:(NSString*)inMessage
- (instancetype) initWithTitle:(NSString*)inTitle message:(NSString*)inMessage
{
self = [super init];
if (!self) return nil;
Expand All @@ -36,7 +36,7 @@ - (id) initWithTitle:(NSString*)inTitle message:(NSString*)inMessage

return self;
}
- (id) initWithTitle:(NSString*)inTitle message:(NSString*)inMessage buttonsWithHandlerAndTitle:(id)firstHandler, ...
- (instancetype) initWithTitle:(NSString*)inTitle message:(NSString*)inMessage buttonsWithHandlerAndTitle:(id)firstHandler, ...
{
self = [self initWithTitle:inTitle message:inMessage];
if (!self) return nil;
Expand Down Expand Up @@ -136,7 +136,7 @@ - (void)alertView:(UIAlertView *)inAlertView clickedButtonAtIndex:(NSInteger)but
cancelButton.handler(inAlertView, buttonIndex);
}
} else {
CBUIAlertViewControllerButton *button = [buttons objectAtIndex:buttonIndex];
CBUIAlertViewControllerButton *button = buttons[buttonIndex];
if (button.handler) {
button.handler(inAlertView, buttonIndex);
}
Expand Down
12 changes: 6 additions & 6 deletions Classes/CBUIAttributedLabel.m
Expand Up @@ -35,7 +35,7 @@ @implementation CBUIAttributedLabel
@synthesize delegate = _delegate;


- (id)initWithFrame:(CGRect)frame {
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (!self) return nil;

Expand All @@ -46,7 +46,7 @@ - (id)initWithFrame:(CGRect)frame {

return self;
}
- (id)initWithCoder:(NSCoder *)aDecoder
- (instancetype)initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithCoder:aDecoder];
if (!self) return nil;
Expand Down Expand Up @@ -83,14 +83,14 @@ - (void)setHighlighted:(BOOL)highlighted

[_attributedText enumerateAttributesInRange:NSMakeRange(0, _attributedText.length) options:0
usingBlock:^(NSDictionary *attrs, NSRange range, BOOL *stop) {
UIColor *textColor = [attrs objectForKey:(id)kCTForegroundColorAttributeName];
UIColor *textColor = attrs[(id)kCTForegroundColorAttributeName];

UIColor *myTargetColor = nil;

if (!textColor || [currentColor isEqual:textColor]) {
myTargetColor = targetColor;
} else {
myTargetColor = [attrs objectForKey:highlighted ? kCBCTHighlightedForegroundColorAttributeName : kCBCTDefaultForegroundColorAttributeName];
myTargetColor = attrs[highlighted ? kCBCTHighlightedForegroundColorAttributeName : kCBCTDefaultForegroundColorAttributeName];
}

if (myTargetColor) {
Expand Down Expand Up @@ -221,7 +221,7 @@ - (void)drawTextInRect:(CGRect)requestedRect

NSDictionary *runAttributes = (__bridge NSDictionary*)CTRunGetAttributes(run);

id attachment = [runAttributes objectForKey:@"NSAttachmentAttributeName"];
id attachment = runAttributes[@"NSAttachmentAttributeName"];
if (attachment) {
CGFloat ascent, descent, leading;
CGFloat width = (CGFloat)CTRunGetTypographicBounds(run, CFRangeMake(0, 0), &ascent, &descent, &leading);
Expand Down Expand Up @@ -259,7 +259,7 @@ - (void)drawTextInRect:(CGRect)requestedRect
}
}

id linkURL = [runAttributes objectForKey:kCBUILinkAttribute];
id linkURL = runAttributes[kCBUILinkAttribute];
if (linkURL) {
CFRange cfRange = CTRunGetStringRange(run);
NSRange runRange = NSMakeRange(cfRange.location, cfRange.length);
Expand Down
2 changes: 1 addition & 1 deletion Classes/CBUIAttributedTableViewCell.m
Expand Up @@ -14,7 +14,7 @@

@implementation CBUIAttributedTableViewCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (!self) return nil;
Expand Down
2 changes: 1 addition & 1 deletion Classes/CBUICircularProgressView.m
Expand Up @@ -12,7 +12,7 @@ @implementation CBUICircularProgressView

@synthesize progress = _progress;

- (id)initWithFrame:(CGRect)frame
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
Expand Down
2 changes: 1 addition & 1 deletion Classes/CBUICollectionViewDataSource.h
Expand Up @@ -40,7 +40,7 @@
@property (nonatomic, assign) BOOL loading;


- (id)initWithCollectionView:(UICollectionView*)collectionView;
- (instancetype)initWithCollectionView:(UICollectionView*)collectionView NS_DESIGNATED_INITIALIZER;

- (id) objectAtIndexPath:(NSIndexPath*)indexPath;

Expand Down
2 changes: 1 addition & 1 deletion Classes/CBUICollectionViewDataSource.m
Expand Up @@ -10,7 +10,7 @@

@implementation CBUICollectionViewDataSource

- (id)initWithCollectionView:(UICollectionView*)collectionView
- (instancetype)initWithCollectionView:(UICollectionView*)collectionView
{
self = [super init];
if (!self) return nil;
Expand Down
4 changes: 2 additions & 2 deletions Classes/CBUICustomAnimationModalSegue.m
Expand Up @@ -102,7 +102,7 @@ - (void) perform

@implementation CBUIPushFromRightModalSegue

- (id)initWithIdentifier:(NSString *)identifier source:(UIViewController *)source destination:(UIViewController *)destination
- (instancetype)initWithIdentifier:(NSString *)identifier source:(UIViewController *)source destination:(UIViewController *)destination
{
self = [super initWithIdentifier:identifier source:source destination:destination];
if (!self) return nil;
Expand All @@ -120,7 +120,7 @@ - (id)initWithIdentifier:(NSString *)identifier source:(UIViewController *)sourc

@implementation CBUIPushFromLeftModalSegue

- (id)initWithIdentifier:(NSString *)identifier source:(UIViewController *)source destination:(UIViewController *)destination
- (instancetype)initWithIdentifier:(NSString *)identifier source:(UIViewController *)source destination:(UIViewController *)destination
{
self = [super initWithIdentifier:identifier source:source destination:destination];
if (!self) return nil;
Expand Down
2 changes: 1 addition & 1 deletion Classes/CBUIDisclosureTriangle.m
Expand Up @@ -13,7 +13,7 @@ @implementation CBUIDisclosureTriangle

@synthesize state;

- (id)initWithFrame:(CGRect)frame {
- (instancetype)initWithFrame:(CGRect)frame {

CGFloat edgeLength = MIN(frame.size.width, frame.size.height);
frame = CGRectMake(CGRectGetMidX(frame) - edgeLength / 2,
Expand Down
8 changes: 4 additions & 4 deletions Classes/CBUIFetchResultsDataSource.h
Expand Up @@ -40,11 +40,11 @@
@property (nonatomic, assign) UITableViewRowAnimation deleteRowAnimation;
@property (nonatomic, assign) UITableViewRowAnimation updateRowAnimation;

- (id) initWithTableView:(UITableView*)tableView
- (instancetype) initWithTableView:(UITableView*)tableView
fetchRequest:(NSFetchRequest*)fetchRequest managedObjectContext:(NSManagedObjectContext*)context
sectionNameKeyPath:(NSString*)sectionNameKeyPath
cacheName:(NSString*)cacheName;
- (id) initWithTableView:(UITableView*)tableView
cacheName:(NSString*)cacheName NS_DESIGNATED_INITIALIZER;
- (instancetype) initWithTableView:(UITableView*)tableView
fetchRequest:(NSFetchRequest*)fetchRequest managedObjectContext:(NSManagedObjectContext*)context
cacheName:(NSString*)cacheName;

Expand All @@ -62,7 +62,7 @@
// ONLY WORKS WITH ONE SECTION!!
- (BOOL) performFetchAndUpdateTableView:(NSError *__autoreleasing*)error;

- (NSDictionary*) updatesDictionary;
@property (NS_NONATOMIC_IOSONLY, readonly, copy) NSDictionary *updatesDictionary;

@end

Expand Down
20 changes: 10 additions & 10 deletions Classes/CBUIFetchResultsDataSource.m
Expand Up @@ -50,7 +50,7 @@ @implementation CBUIFetchResultsDataSource

@synthesize allowsDeletion = _allowsDeletion;

- (id) initWithTableView:(UITableView*)tableView
- (instancetype) initWithTableView:(UITableView*)tableView
fetchRequest:(NSFetchRequest*)fetchRequest managedObjectContext:(NSManagedObjectContext*)context
sectionNameKeyPath:(NSString*)sectionNameKeyPath
cacheName:(NSString*)cacheName
Expand Down Expand Up @@ -85,7 +85,7 @@ - (id) initWithTableView:(UITableView*)tableView

return self;
}
- (id) initWithTableView:(UITableView*)tableView
- (instancetype) initWithTableView:(UITableView*)tableView
fetchRequest:(NSFetchRequest*)fetchRequest managedObjectContext:(NSManagedObjectContext*)context
cacheName:(NSString*)cacheName
{
Expand Down Expand Up @@ -141,16 +141,16 @@ - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
}
- (id<NSFetchedResultsSectionInfo>) infoForSectionAtIndex:(NSInteger)section
{
return [[_fetchedResultsController sections] objectAtIndex:section];
return [_fetchedResultsController sections][section];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
id <NSFetchedResultsSectionInfo> sectionInfo = [[_fetchedResultsController sections] objectAtIndex:section];
id <NSFetchedResultsSectionInfo> sectionInfo = [_fetchedResultsController sections][section];
return [sectionInfo numberOfObjects];
}

- (NSString *) tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
id<NSFetchedResultsSectionInfo> sectionInfo = [[_fetchedResultsController sections] objectAtIndex:section];
id<NSFetchedResultsSectionInfo> sectionInfo = [_fetchedResultsController sections][section];
return [sectionInfo name];
}

Expand Down Expand Up @@ -438,19 +438,19 @@ - (NSDictionary*) updatesDictionary;
{
NSMutableDictionary *result = [NSMutableDictionary dictionary];
if (self.deletedSectionIndexes.count > 0) {
[result setObject:self.deletedSectionIndexes forKey:@"DeletedSections"];
result[@"DeletedSections"] = self.deletedSectionIndexes;
}
if (self.insertedSectionIndexes.count > 0) {
[result setObject:self.insertedSectionIndexes forKey:@"InsertedSections"];
result[@"InsertedSections"] = self.insertedSectionIndexes;
}
if (self.deletedRowIndexPaths.count > 0) {
[result setObject:self.deletedRowIndexPaths forKey:@"DeletedRows"];
result[@"DeletedRows"] = self.deletedRowIndexPaths;
}
if (self.insertedRowIndexPaths.count > 0) {
[result setObject:self.insertedRowIndexPaths forKey:@"InsertedRows"];
result[@"InsertedRows"] = self.insertedRowIndexPaths;
}
if (self.updatedRowIndexPaths.count > 0) {
[result setObject:self.updatedRowIndexPaths forKey:@"UpdatedRows"];
result[@"UpdatedRows"] = self.updatedRowIndexPaths;
}
return result;
}
Expand Down
8 changes: 4 additions & 4 deletions Classes/CBUIFetchResultsReorderDataSource.m
Expand Up @@ -10,7 +10,7 @@

@implementation CBUIFetchResultsReorderDataSource

- (id) initWithTableView:(UITableView*)tableView
- (instancetype) initWithTableView:(UITableView*)tableView
fetchRequest:(NSFetchRequest*)fetchRequest managedObjectContext:(NSManagedObjectContext*)context
sectionNameKeyPath:(NSString*)sectionNameKeyPath
cacheName:(NSString*)cacheName
Expand All @@ -31,17 +31,17 @@ - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath
{
NSMutableArray *items = [self.fetchedResultsController.fetchedObjects mutableCopy];
id object = [items objectAtIndex:fromIndexPath.row];
id object = items[fromIndexPath.row];
[items removeObjectAtIndex:fromIndexPath.row];
[items insertObject:object atIndex:toIndexPath.row];

NSString *key = [[self.fetchedResultsController.fetchRequest.sortDescriptors objectAtIndex:0] key];
NSString *key = [(self.fetchedResultsController.fetchRequest.sortDescriptors)[0] key];

int number = 1;
for (id item in items) {
NSNumber *oldNo = [item valueForKey:key];
if ([oldNo intValue] != number) {
[item setValue:[NSNumber numberWithInt:number] forKey:key];
[item setValue:@(number) forKey:key];
}

number++;
Expand Down
6 changes: 3 additions & 3 deletions Classes/CBUIFetchedResultsCollectionViewDataSource.h
Expand Up @@ -13,11 +13,11 @@

@property (readonly, strong) NSFetchedResultsController *fetchedResultsController;

- (id) initWithCollectionView:(UICollectionView*)collectionView
- (instancetype) initWithCollectionView:(UICollectionView*)collectionView
fetchRequest:(NSFetchRequest*)fetchRequest managedObjectContext:(NSManagedObjectContext*)context
sectionNameKeyPath:(NSString*)sectionNameKeyPath
cacheName:(NSString*)cacheName;
- (id) initWithCollectionView:(UICollectionView*)collectionView
cacheName:(NSString*)cacheName NS_DESIGNATED_INITIALIZER;
- (instancetype) initWithCollectionView:(UICollectionView*)collectionView
fetchRequest:(NSFetchRequest*)fetchRequest
managedObjectContext:(NSManagedObjectContext*)context
cacheName:(NSString*)cacheName;
Expand Down

0 comments on commit abf35a6

Please sign in to comment.