Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS 9 warning reductions #12

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
1 change: 1 addition & 0 deletions AltBeacon/Source/AltBeacon.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ typedef enum {

@property (nonatomic, readonly) BOOL isDetecting;
@property (nonatomic, readonly) BOOL isBroadcasting;
@property (nonatomic, readonly) NSString* identifier;

- (void)startDetecting;
- (void)stopDetecting;
Expand Down
11 changes: 5 additions & 6 deletions AltBeacon/Source/AltBeacon.m
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,10 @@
#define ALT_BEACON_CHARACTERISTIC @"A05F9DF4-9D54-4600-9224-983B75B9D154"

@interface AltBeacon () <CBPeripheralManagerDelegate, CBCentralManagerDelegate, CBPeripheralDelegate>
@property (nonatomic, readwrite) NSString* identifier;
@end

@implementation AltBeacon {
NSString *identifier;

CBCentralManager *centralManager;
CBPeripheralManager *peripheralManager;

Expand All @@ -76,7 +75,7 @@ @implementation AltBeacon {

- (id)initWithIdentifier:(NSString *)theIdentifier {
if ((self = [super init])) {
identifier = theIdentifier;
self.identifier = theIdentifier;

uuidsDetected = [[NSMutableDictionary alloc] init];
peripheralDetected = [[NSMutableDictionary alloc] init];
Expand Down Expand Up @@ -176,11 +175,11 @@ - (void)startDetectingBeacons {


- (void) peripheral:(CBPeripheral *)peripheral
didUpdateValueForCharacteristic:(CBCharacteristic *)characteristic
didUpdateValueForCharacteristic:(CBCharacteristic *)peripheralCharacteristic
error:(NSError *)error {

if (!error) {
NSData *data = characteristic.value;
NSData *data = peripheralCharacteristic.value;
NSString *newStr = [[NSString alloc] initWithData:data
encoding:NSUTF8StringEncoding];

Expand Down Expand Up @@ -314,7 +313,7 @@ - (void)startAdvertising {
[CBUUID UUIDWithString:ALT_BEACON_CHARACTERISTIC];

CBMutableService *service = [[CBMutableService alloc] initWithType:altBeaconServiceUUID primary:YES];
NSString *strUUID = identifier;
NSString *strUUID = self.identifier;
NSData *dataUUID = [strUUID dataUsingEncoding:NSUTF8StringEncoding];

characteristic =
Expand Down
17 changes: 9 additions & 8 deletions AltBeacon/Source/Extension/NSDate+Ext.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,38 +42,39 @@ - (BOOL)extHasExpired {
}

- (NSUInteger)extMonth {
NSDateComponents *components = [[NSCalendar currentCalendar] components:NSMonthCalendarUnit fromDate:self];
NSDateComponents *components = [[NSCalendar currentCalendar] components:NSCalendarUnitMonth fromDate:self];
return components.month;
}

- (NSUInteger)extDay {
NSDateComponents *components = [[NSCalendar currentCalendar] components:NSDayCalendarUnit fromDate:self];
NSDateComponents *components = [[NSCalendar currentCalendar] components:NSCalendarUnitDay fromDate:self];
return components.day;
}

- (NSUInteger)extYear {
NSDateComponents *components = [[NSCalendar currentCalendar] components:NSYearCalendarUnit fromDate:self];
NSDateComponents *components = [[NSCalendar currentCalendar] components:NSCalendarUnitYear fromDate:self];
return components.year;
}

- (NSUInteger)extDaysInMonth {
NSRange days = [[NSCalendar currentCalendar] rangeOfUnit:NSDayCalendarUnit
inUnit:NSMonthCalendarUnit
NSRange days = [[NSCalendar currentCalendar] rangeOfUnit:NSCalendarUnitDay
inUnit:NSCalendarUnitMonth
forDate:self];

return days.length;
}

- (NSUInteger)extWeekday {
NSDateComponents *components = [[NSCalendar currentCalendar] components:NSWeekdayCalendarUnit fromDate:self];
NSDateComponents *components = [[NSCalendar currentCalendar] components:NSCalendarUnitWeekday fromDate:self];
return components.weekday;
}

+ (NSArray *)extGenerateMonthsFromDate:(NSDate *)fromDate toDate:(NSDate *)toDate {
NSMutableArray *months = [[NSMutableArray alloc] init];
[months addObject:fromDate];

NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];

NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
NSDateComponents *offsetComponents = [[NSDateComponents alloc] init];
[offsetComponents setMonth:1];

Expand All @@ -87,7 +88,7 @@ + (NSArray *)extGenerateMonthsFromDate:(NSDate *)fromDate toDate:(NSDate *)toDat
}

- (NSUInteger)extLastDayOfMonth {
NSRange daysRange = [[NSCalendar currentCalendar] rangeOfUnit:NSDayCalendarUnit inUnit:NSMonthCalendarUnit forDate:self];
NSRange daysRange = [[NSCalendar currentCalendar] rangeOfUnit:NSCalendarUnitDay inUnit:NSCalendarUnitMonth forDate:self];

return daysRange.length;
}
Expand Down
1 change: 1 addition & 0 deletions AltBeacon/Source/Extension/NSFileManager+Ext.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

#import <Foundation/Foundation.h>
@import CoreGraphics;

@interface NSFileManager(Ext)
- (CGFloat)extFileSizeInMegaBytesAtPath:(NSString *)path;
Expand Down
2 changes: 2 additions & 0 deletions AltBeacon/Source/Extension/NSString+Ext.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
// Copyright (c) 2011 Ben Ford All rights reserved.
//

@import CoreGraphics;
@import UIKit;
#import <Foundation/Foundation.h>

typedef enum {
Expand Down
2 changes: 1 addition & 1 deletion AltBeacon/Source/Util/EasedValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.


@import CoreGraphics;
#import <Foundation/Foundation.h>

/**
Expand Down
2 changes: 1 addition & 1 deletion AltBeacon/Source/Util/EasedValue.m
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ - (void)update
currentValue += velocity;

// limit how small the ease can get
if(fabsf(targetValue - currentValue) < 0.001f){
if(fabs(targetValue - currentValue) < 0.001f){
currentValue = targetValue;
velocity = 0.0f;
}
Expand Down