Skip to content

Commit

Permalink
Merge pull request #387 from box/103warnings
Browse files Browse the repository at this point in the history
Fix warnings for iOS 10.3
  • Loading branch information
adempsey authored May 3, 2017
2 parents acd451e + e37c684 commit f4b06f8
Show file tree
Hide file tree
Showing 16 changed files with 89 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#import "BOXAppToAppApplication.h"

#import "BOXLog.h"
#import "NSString+BoxURLHelper.h"
#import "NSString+BOXURLHelper.h"


@interface BOXAppToAppAnnotationBuilder()
Expand Down Expand Up @@ -103,7 +103,7 @@ + (NSString *)stringByDestructivelyParsingInfo:(NSMutableDictionary *)info forKe

if (result != nil)
{
result = [result stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
result = [result stringByRemovingPercentEncoding];
[info removeObjectForKey:key];
}

Expand Down Expand Up @@ -156,7 +156,7 @@ + (NSString *)stringFromAnnotationString:(NSString *)string
{
NSString *result = string;
// percent de-encode the string
result = [result stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
result = [result stringByRemovingPercentEncoding];

return result;
}
Expand Down
2 changes: 1 addition & 1 deletion BoxContentSDK/BoxContentSDK/AppToApp/BOXAppToAppMessage.m
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ + (NSMutableDictionary *)infoDictionaryFromOpenURL:(NSURL *)openURL
{
NSString *key = pair[0];
NSString *value = pair[1];
value = [value stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
value = [value stringByRemovingPercentEncoding];
result[key] = value;
}
}
Expand Down
4 changes: 2 additions & 2 deletions BoxContentSDK/BoxContentSDK/BOXURLRequestSerialization.m
Original file line number Diff line number Diff line change
Expand Up @@ -1393,7 +1393,7 @@ - (instancetype)initWithCoder:(NSCoder *)decoder {
return nil;
}

self.format = (NSPropertyListFormat)[[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(format))] unsignedIntegerValue];
self.format = (NSPropertyListFormat)[[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector((format)))] unsignedIntegerValue];
self.writeOptions = [[decoder decodeObjectOfClass:[NSNumber class] forKey:NSStringFromSelector(@selector(writeOptions))] unsignedIntegerValue];

return self;
Expand All @@ -1402,7 +1402,7 @@ - (instancetype)initWithCoder:(NSCoder *)decoder {
- (void)encodeWithCoder:(NSCoder *)coder {
[super encodeWithCoder:coder];

[coder encodeInteger:self.format forKey:NSStringFromSelector(@selector(format))];
[coder encodeInteger:self.format forKey:NSStringFromSelector(@selector((format)))];
[coder encodeObject:@(self.writeOptions) forKey:NSStringFromSelector(@selector(writeOptions))];
}

Expand Down
84 changes: 70 additions & 14 deletions BoxContentSDK/BoxContentSDK/BOXURLSessionManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ - (NSURLSession *)backgroundSessionForId:(NSString *)backgroundSessionId
}
}

- (void)pendingBackgroundDownloadUploadSessionTasks:(void (^)(NSArray<NSURLSessionUploadTask *> * uploadTasks, NSArray<NSURLSessionDownloadTask *> * downloadTasks))completionBlock
- (void)pendingBackgroundDownloadUploadSessionTasks:(void (^)(NSArray<NSURLSessionUploadTask *> * _Nullable uploadTasks, NSArray<NSURLSessionDownloadTask *> * _Nullable downloadTasks))completionBlock
{
if (completionBlock != nil) {
if (self.supportBackgroundSessionTasks == NO) {
Expand All @@ -360,7 +360,7 @@ - (void)associateProgressSessionTask:(NSURLSessionTask *)sessionTask withTaskDel
[self associateSessionId:nil sessionTask:sessionTask withTaskDelegate:taskDelegate];
}

- (void)associateSessionId:(NSString *)sessionId sessionTask:(NSURLSessionTask *)sessionTask withTaskDelegate:(id <BOXURLSessionTaskDelegate> )taskDelegate
- (void)associateSessionId:(nullable NSString *)sessionId sessionTask:(NSURLSessionTask *)sessionTask withTaskDelegate:(nullable id<BOXURLSessionTaskDelegate> )taskDelegate
{
NSUInteger sessionTaskId = sessionTask.taskIdentifier;

Expand Down Expand Up @@ -415,20 +415,51 @@ - (NSURLSessionUploadTask *)foregroundUploadTaskWithStreamedRequest:(NSURLReques
return task;
}

- (NSURLSessionDownloadTask *)backgroundDownloadTaskWithRequest:(NSURLRequest *)request taskDelegate:(id <BOXURLSessionDownloadTaskDelegate>)taskDelegate userId:(NSString *)userId associateId:(NSString *)associateId error:(NSError **)error
- (NSURLSessionDownloadTask *)backgroundDownloadTaskWithRequest:(NSURLRequest *)request
taskDelegate:(id <BOXURLSessionDownloadTaskDelegate>)taskDelegate
userId:(NSString *)userId
associateId:(NSString *)associateId
error:(NSError **)error
{
if (request == nil || taskDelegate == nil || userId == nil || associateId == nil) {
return nil;
}
return [self backgroundTaskWithRequest:request orUploadFromFile:nil taskDelegate:taskDelegate userId:userId associateId:associateId error:error];

NSURLSessionTask *task = [self backgroundTaskWithRequest:request
orUploadFromFile:nil
taskDelegate:taskDelegate
userId:userId
associateId:associateId
error:error];
if ([task isKindOfClass:[NSURLSessionDownloadTask class]]) {
return (NSURLSessionDownloadTask *) task;
}

return nil;
}

- (NSURLSessionUploadTask *)backgroundUploadTaskWithRequest:(NSURLRequest *)request fromFile:(NSURL *)fileURL taskDelegate:(id <BOXURLSessionUploadTaskDelegate>)taskDelegate userId:(NSString *)userId associateId:(NSString *)associateId error:(NSError **)error
- (NSURLSessionUploadTask *)backgroundUploadTaskWithRequest:(NSURLRequest *)request
fromFile:(NSURL *)fileURL
taskDelegate:(id <BOXURLSessionUploadTaskDelegate>)taskDelegate
userId:(NSString *)userId
associateId:(NSString *)associateId
error:(NSError **)error
{
if (request == nil || fileURL == nil || taskDelegate == nil || userId == nil || associateId == nil) {
return nil;
}
return [self backgroundTaskWithRequest:request orUploadFromFile:fileURL taskDelegate:taskDelegate userId:userId associateId:associateId error:error];

NSURLSessionTask *task = [self backgroundTaskWithRequest:request
orUploadFromFile:fileURL
taskDelegate:taskDelegate
userId:userId
associateId:associateId
error:error];
if ([task isKindOfClass:[NSURLSessionUploadTask class]]) {
return (NSURLSessionUploadTask *) task;
}

return nil;
}

- (BOXURLSessionTaskCachedInfo *)sessionTaskCompletedCachedInfoGivenUserId:(NSString *)userId associateId:(NSString *)associateId error:(NSError **)error
Expand Down Expand Up @@ -536,7 +567,8 @@ - (void)cancelOnGoingSessionTasksForUserId:(NSString *)userId error:(NSError **)

#pragma mark - Private Helpers

- (BOOL)cleanUpBackgroundSessionId:(NSString *)backgroundSessionId error:(NSError **)error
- (BOOL)cleanUpBackgroundSessionId:(NSString *)backgroundSessionId
error:(NSError **)error
{
@synchronized (self.backgroundSessionIdToSessionTask) {
[self.backgroundSessionIdToSessionTask removeObjectForKey:backgroundSessionId];
Expand All @@ -550,7 +582,8 @@ - (BOOL)cleanUpBackgroundSessionId:(NSString *)backgroundSessionId error:(NSErro
// Return background session Id and sessionTask for this userId and associateId
// If we have never seen the combination of userId and associateId before, return nil
// If we have, backgroundSessionId will not be nil, but sessionTask might be nil if the task has completed
- (BOXBackgroundSessionIdAndTask *)existingBackgroundSessionTaskGivenUserId:(NSString *)userId associateId:(NSString *)associateId
- (BOXBackgroundSessionIdAndTask *)existingBackgroundSessionTaskGivenUserId:(NSString *)userId
associateId:(NSString *)associateId
{
NSError *error = nil;
BOXBackgroundSessionIdAndTask *returned = nil;
Expand All @@ -572,7 +605,12 @@ - (BOXBackgroundSessionIdAndTask *)existingBackgroundSessionTaskGivenUserId:(NSS
// before we populate pending tasks upon app restart, we will return nil,
// unless the task was a completed background download task with valid resume data,
// re-create the download task with resume data and return that
- (NSURLSessionTask *)backgroundTaskWithRequest:(NSURLRequest *)request orUploadFromFile:(nullable NSURL *)uploadFromFileURL taskDelegate:(id <BOXURLSessionTaskDelegate>)taskDelegate userId:(NSString *)userId associateId:(NSString *)associateId error:(NSError **)outError
- (NSURLSessionTask *)backgroundTaskWithRequest:(NSURLRequest *)request
orUploadFromFile:(nullable NSURL *)uploadFromFileURL
taskDelegate:(id <BOXURLSessionTaskDelegate>)taskDelegate
userId:(NSString *)userId
associateId:(NSString *)associateId
error:(NSError **)outError
{
if (self.didFinishSettingUpBackgroundSession == NO) {
//trying to get a background session task before setting up background session completes
Expand Down Expand Up @@ -620,7 +658,12 @@ - (NSURLSessionTask *)backgroundTaskWithRequest:(NSURLRequest *)request orUpload
}

if (sessionTask != nil) {
BOOL success = [self persistBackgroundSessionTaskWithSessionId:backgroundSessionId sessionTask:sessionTask taskDelegate:taskDelegate userId:userId associateId:associateId error:&error];
BOOL success = [self persistBackgroundSessionTaskWithSessionId:backgroundSessionId
sessionTask:sessionTask
taskDelegate:taskDelegate
userId:userId
associateId:associateId
error:&error];
if (success == NO || error != nil) {
//if we fail to persist data needed to support background session tasks, cancel the one we created and do not return it
[sessionTask cancel];
Expand All @@ -640,19 +683,32 @@ - (NSURLSessionTask *)backgroundTaskWithRequest:(NSURLRequest *)request orUpload
return sessionTask;
}

- (BOOL)persistBackgroundSessionTaskWithSessionId:(NSString *)backgroundSessionId sessionTask:(NSURLSessionTask *)task taskDelegate:(id <BOXURLSessionDownloadTaskDelegate>)taskDelegate userId:(NSString *)userId associateId:(NSString *)associateId error:(NSError **)error
- (BOOL)persistBackgroundSessionTaskWithSessionId:(NSString *)backgroundSessionId
sessionTask:(NSURLSessionTask *)task
taskDelegate:(id <BOXURLSessionTaskDelegate>)taskDelegate
userId:(NSString *)userId
associateId:(NSString *)associateId
error:(NSError **)error
{
if (task == nil || taskDelegate == nil || userId == nil || associateId == nil) {
if (error != nil) {
*error = [[NSError alloc] initWithDomain:BOXContentSDKErrorDomain code:BOXContentSDKURLSessionCacheErrorInvalidUserIdOrAssociateId userInfo:nil];
*error = [[NSError alloc] initWithDomain:BOXContentSDKErrorDomain
code:BOXContentSDKURLSessionCacheErrorInvalidUserIdOrAssociateId
userInfo:nil];
}
return NO;
}

[self associateSessionId:backgroundSessionId sessionTask:task withTaskDelegate:taskDelegate];
[self associateSessionId:backgroundSessionId
sessionTask:task
withTaskDelegate:taskDelegate];

//cache background task if have not
return [self.cacheClient cacheUserId:userId associateId:associateId backgroundSessionId:backgroundSessionId sessionTaskId:task.taskIdentifier error:&error];
return [self.cacheClient cacheUserId:userId
associateId:associateId
backgroundSessionId:backgroundSessionId
sessionTaskId:task.taskIdentifier
error:error];
}

- (id<BOXURLSessionTaskDelegate>)taskDelegateForSessionId:(NSString *)sessionId sessionTaskId:(NSUInteger)sessionTaskId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//

#import "NSDate+BOXContentSDKAdditions.h"
#import "BoxISO8601DateFormatter.h"
#import "BOXISO8601DateFormatter.h"

@implementation NSDate (BOXContentSDKAdditions)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,8 @@ - (NSString *)box_fileNameExtensionAccountingForEmptyName

- (NSString *)box_stringByAddingURLPercentEscapes
{
return (__bridge_transfer NSString *)CFURLCreateStringByAddingPercentEscapes(NULL,
(__bridge CFStringRef)self,
NULL,
(CFStringRef)@"!*'();:@&=+$,/?%#[]",
kCFStringEncodingUTF8);
NSCharacterSet *allowedCharacters = [[NSCharacterSet characterSetWithCharactersInString:@"!*'();:@&=+$,/?%#[]"] invertedSet];
return [self stringByAddingPercentEncodingWithAllowedCharacters:allowedCharacters];
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,8 @@ + (NSString *)box_stringWithString:(NSString *)string URLEncoded:(BOOL)encoded
{
if (encoded)
{
string = (__bridge_transfer NSString *) CFURLCreateStringByAddingPercentEscapes(NULL,
(__bridge CFStringRef) string,
NULL,
(CFStringRef)@"!*'();:@&=+$,/?%#[]",
kCFStringEncodingUTF8);
NSCharacterSet *allowedCharacters = [[NSCharacterSet characterSetWithCharactersInString:@"!*'();:@&=+$,/?%#[]"] invertedSet];
string = [string stringByAddingPercentEncodingWithAllowedCharacters:allowedCharacters];
}

return [NSString stringWithString:string];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//
//

#import <BoxContentSDK/BoxContentSDK.h>
#import <BoxContentSDK/BOXContentSDK.h>

@class BOXRecentItemsRequest;

Expand Down
2 changes: 1 addition & 1 deletion BoxContentSDK/BoxContentSDK/Models/BOXMetadataTemplate.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//

#import "BOXMetadataTemplate.h"
#import "BoxISO8601DateFormatter.h"
#import "BOXISO8601DateFormatter.h"
#import "BOXMetadataTemplateField.h"

@implementation BOXMetadataTemplate
Expand Down
2 changes: 1 addition & 1 deletion BoxContentSDK/BoxContentSDK/Models/BOXModel.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#import "BOXModel.h"

#import "BoxISO8601DateFormatter.h"
#import "BOXISO8601DateFormatter.h"

@implementation BOXModel

Expand Down
2 changes: 1 addition & 1 deletion BoxContentSDK/BoxContentSDK/Models/BOXRecentItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//
//

#import <BoxContentSDK/BoxContentSDK.h>
#import <BoxContentSDK/BOXContentSDK.h>

/**
Represents an item recently interacted with by the current user.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#import "BOXAPIOperation_Private.h"
#import "BOXAPIAppUsersAuthOperation.h"
#import "BoxContentSDKErrors.h"
#import "BOXContentSDKErrors.h"
#import "BOXLog.h"
#import "BOXAbstractSession.h"

Expand All @@ -23,7 +23,7 @@ - (void)start

if ([self isReady]) {
self.state = BOXAPIOperationStateExecuting;

[self performSelector:@selector(executeOperation)
onThread:[[self class] globalAPIOperationNetworkThread]
withObject:nil
Expand Down
13 changes: 0 additions & 13 deletions BoxContentSDK/BoxContentSDK/Operations/BOXStreamOperation.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,6 @@ typedef void (^BOXAPIStreamProgressBlock)(NSData *data, long long expectedTotalB
*/
- (void)performCompletionCallback;

/**
* When data is successfully received over the network,
* this method is called to trigger progressBlock.
* @see progressBlock
*/
- (void)performProgressCallback;

/**
* The fileID associated with this download request. This value is passed to progressBlock.
* @see progressBlock
Expand All @@ -95,12 +88,6 @@ typedef void (^BOXAPIStreamProgressBlock)(NSData *data, long long expectedTotalB

/** @name Overridden methods */

/**
* In addition to calling [super]([BOXAPIAuthenticatedOperation prepareAPIRequest]), schedule outputStream
* in the current run loop and set `outputStream.delegate` to `self`.
*/
- (void)prepareAPIRequest;

/**
* BOXAPIDataOperation should only ever be GET requests so there should not be a body.
*
Expand Down
2 changes: 0 additions & 2 deletions BoxContentSDK/BoxContentSDK/Operations/BOXStreamOperation.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ @interface BOXStreamOperation () <BOXURLSessionDownloadTaskDelegate>

@property (nonatomic, readwrite, assign) unsigned long long bytesReceived;

- (void)writeDataToOutputStream;

- (long long)contentLength;

@end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#import "BOXMetadataTemplateRequest.h"
#import "BOXRequest+Metadata.h"
#import "BoxContentSDKConstants.h"
#import "BOXContentSDKConstants.h"
#import "BOXAPIOperation.h"
#import "BOXAPIJSONOperation.h"
#import "BOXRequest_Private.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//
//

#import <BoxContentSDK/BoxContentSDK.h>
#import <BoxContentSDK/BOXContentSDK.h>

@interface BOXRecentItemsRequest : BOXRequest

Expand Down

0 comments on commit f4b06f8

Please sign in to comment.