diff --git a/Examples/iOSExplorer/iOSExplorer.xcodeproj/project.pbxproj b/Examples/iOSExplorer/iOSExplorer.xcodeproj/project.pbxproj index c095378..b7b90a3 100644 --- a/Examples/iOSExplorer/iOSExplorer.xcodeproj/project.pbxproj +++ b/Examples/iOSExplorer/iOSExplorer.xcodeproj/project.pbxproj @@ -7,8 +7,6 @@ objects = { /* Begin PBXBuildFile section */ - 10007C751B31D88C00E4ED17 /* ADAL_iPad_Storyboard.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 10007C731B31D88C00E4ED17 /* ADAL_iPad_Storyboard.storyboard */; }; - 10007C761B31D88C00E4ED17 /* ADAL_iPhone_Storyboard.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 10007C741B31D88C00E4ED17 /* ADAL_iPhone_Storyboard.storyboard */; }; 1003AADC1B0E52460039017A /* ODXActionController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1003AADB1B0E52460039017A /* ODXActionController.m */; }; 105857821B9A1F8000B71550 /* ODXProgressViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 105857811B9A1F8000B71550 /* ODXProgressViewController.m */; }; 106DAAE61AF82DE9001FF917 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 106DAAE51AF82DE9001FF917 /* main.m */; }; @@ -20,6 +18,8 @@ 106DAB3E1AF82E77001FF917 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 106DAB3A1AF82E77001FF917 /* Main.storyboard */; }; 106DAB3F1AF82E77001FF917 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 106DAB3C1AF82E77001FF917 /* Images.xcassets */; }; 51037E9C92F08CDC45500AAD /* libPods-iOSExplorer.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D3DFCFC19ED153A38DAF7A55 /* libPods-iOSExplorer.a */; }; + 96DEE06E1BC5E4F700F02AF8 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 96DEE06A1BC5E4F700F02AF8 /* LaunchScreen.xib */; settings = {ASSET_TAGS = (); }; }; + 96DEE06F1BC5E4F700F02AF8 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 96DEE06C1BC5E4F700F02AF8 /* Main.storyboard */; settings = {ASSET_TAGS = (); }; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -35,8 +35,6 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ - 10007C731B31D88C00E4ED17 /* ADAL_iPad_Storyboard.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = ADAL_iPad_Storyboard.storyboard; path = ../../../OneDriveSDK/Pods/ADALiOS/ADALiOS/ADALiOS/ADAL_iPad_Storyboard.storyboard; sourceTree = ""; }; - 10007C741B31D88C00E4ED17 /* ADAL_iPhone_Storyboard.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = ADAL_iPhone_Storyboard.storyboard; path = ../../../OneDriveSDK/Pods/ADALiOS/ADALiOS/ADALiOS/ADAL_iPhone_Storyboard.storyboard; sourceTree = ""; }; 1003AADA1B0E52460039017A /* ODXActionController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ODXActionController.h; path = iOSExplorer/ODXActionController.h; sourceTree = SOURCE_ROOT; }; 1003AADB1B0E52460039017A /* ODXActionController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ODXActionController.m; path = iOSExplorer/ODXActionController.m; sourceTree = SOURCE_ROOT; }; 105857801B9A1F8000B71550 /* ODXProgressViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ODXProgressViewController.h; sourceTree = ""; }; @@ -55,6 +53,8 @@ 106DAB391AF82E77001FF917 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = LaunchScreen.xib; sourceTree = ""; }; 106DAB3B1AF82E77001FF917 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Main.storyboard; sourceTree = ""; }; 106DAB3C1AF82E77001FF917 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; + 96DEE06B1BC5E4F700F02AF8 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; + 96DEE06D1BC5E4F700F02AF8 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; CB0C0620E9767D1127AEF938 /* Pods-iOSExplorer.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-iOSExplorer.debug.xcconfig"; path = "Pods/Target Support Files/Pods-iOSExplorer/Pods-iOSExplorer.debug.xcconfig"; sourceTree = ""; }; D3DFCFC19ED153A38DAF7A55 /* libPods-iOSExplorer.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-iOSExplorer.a"; sourceTree = BUILT_PRODUCTS_DIR; }; FBDADC01A80AB5DE8181D87E /* Pods-iOSExplorer.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-iOSExplorer.release.xcconfig"; path = "Pods/Target Support Files/Pods-iOSExplorer/Pods-iOSExplorer.release.xcconfig"; sourceTree = ""; }; @@ -75,8 +75,8 @@ 10007C721B31D86800E4ED17 /* Resources */ = { isa = PBXGroup; children = ( - 10007C731B31D88C00E4ED17 /* ADAL_iPad_Storyboard.storyboard */, - 10007C741B31D88C00E4ED17 /* ADAL_iPhone_Storyboard.storyboard */, + 96DEE06A1BC5E4F700F02AF8 /* LaunchScreen.xib */, + 96DEE06C1BC5E4F700F02AF8 /* Main.storyboard */, ); name = Resources; sourceTree = ""; @@ -225,10 +225,10 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 96DEE06E1BC5E4F700F02AF8 /* LaunchScreen.xib in Resources */, + 96DEE06F1BC5E4F700F02AF8 /* Main.storyboard in Resources */, 106DAB3F1AF82E77001FF917 /* Images.xcassets in Resources */, - 10007C751B31D88C00E4ED17 /* ADAL_iPad_Storyboard.storyboard in Resources */, 106DAB3D1AF82E77001FF917 /* LaunchScreen.xib in Resources */, - 10007C761B31D88C00E4ED17 /* ADAL_iPhone_Storyboard.storyboard in Resources */, 106DAB3E1AF82E77001FF917 /* Main.storyboard in Resources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -302,6 +302,22 @@ name = Main.storyboard; sourceTree = ""; }; + 96DEE06A1BC5E4F700F02AF8 /* LaunchScreen.xib */ = { + isa = PBXVariantGroup; + children = ( + 96DEE06B1BC5E4F700F02AF8 /* Base */, + ); + name = LaunchScreen.xib; + sourceTree = ""; + }; + 96DEE06C1BC5E4F700F02AF8 /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 96DEE06D1BC5E4F700F02AF8 /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ diff --git a/OneDriveSDK.podspec b/OneDriveSDK.podspec index 662c50a..b8e84c3 100644 --- a/OneDriveSDK.podspec +++ b/OneDriveSDK.podspec @@ -2,7 +2,7 @@ Pod::Spec.new do |s| s.name = "OneDriveSDK" - s.version = "1.0.4" + s.version = "1.0.5" s.summary = "OneDrive iOS SDK" s.description = <<-DESC @@ -11,7 +11,7 @@ Pod::Spec.new do |s| s.homepage = "https://dev.onedrive.com" - + s.license = { :type => "MIT", :file => "LICENSE.txt" } @@ -24,12 +24,12 @@ Pod::Spec.new do |s| s.source = { :git => "https://github.com/OneDrive/onedrive-sdk-ios.git", :tag => "#{s.version}"} - s.source_files = "OneDriveSDK/OneDriveSDK/OneDriveSDK.h" - s.public_header_files = "OneDriveSDK/OneDriveSDK/OneDriveSDK.h" + s.source_files = "OneDriveSDK/OneDriveSDK/OneDriveSDK.h" + s.public_header_files = "OneDriveSDK/OneDriveSDK/OneDriveSDK.h" s.exclude_files = "Examples/*","OneDriveSDK/Test/*" - + s.subspec "Common" do |odp| odp.source_files = "OneDriveSDK/Common/*.{h,m}" odp.public_header_files = "OneDriveSDK/Common/*.h" @@ -38,12 +38,12 @@ Pod::Spec.new do |s| s.subspec "Implementations" do |usm| usm.dependency 'OneDriveSDK/Common' usm.source_files = "OneDriveSDK/OneDriveSDK/ODURLSessionManager/*{h,m}", "OneDriveSDK/OneDriveSDK/*{h,m}" - usm.public_header_files = "OneDriveSDK/OneDriveSDK/**/*.h" + usm.public_header_files = "OneDriveSDK/OneDriveSDK/**/*.h" end s.subspec "Auth" do |oda| - oda.dependency 'ADALiOS', '~> 1.0.2' + oda.dependency 'ADALiOS', '~> 1.2.4' oda.dependency 'OneDriveSDK/Common' oda.source_files = "OneDriveSDK/Auth/*.{h,m}", "OneDriveSDK/Accounts/*.{h,m}" @@ -56,7 +56,7 @@ Pod::Spec.new do |s| core.source_files = "OneDriveSDK/OneDriveCoreSDK/**/*.{h,m}" core.public_header_files = "OneDriveSDK/OneDriveCoreSDK/**/*.h" - + end s.subspec "Extensions" do |ext| diff --git a/OneDriveSDK/Accounts/ODServiceInfoProvider.m b/OneDriveSDK/Accounts/ODServiceInfoProvider.m index ea4f8dc..d4be786 100644 --- a/OneDriveSDK/Accounts/ODServiceInfoProvider.m +++ b/OneDriveSDK/Accounts/ODServiceInfoProvider.m @@ -39,8 +39,8 @@ @interface ODServiceInfoProvider() @implementation ODServiceInfoProvider - (void)getServiceInfoWithViewController:(UIViewController *)viewController - appConfiguration:(ODAppConfiguration *)appConfig - completion:(disambiguationCompletion)completionHandler; + appConfiguration:(ODAppConfiguration *)appConfig + completion:(disambiguationCompletion)completionHandler; { NSParameterAssert(viewController); NSParameterAssert(appConfig); @@ -70,7 +70,7 @@ - (void)getServiceInfoWithViewController:(UIViewController *)viewController }]; dispatch_async(dispatch_get_main_queue(), ^(){ UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:discoveryViewController]; - navController.modalPresentationStyle = UIModalPresentationFormSheet; + navController.modalPresentationStyle = viewController.modalPresentationStyle; UIViewController *viewControllerToPresentOn = viewController; while (viewControllerToPresentOn.presentedViewController) { viewControllerToPresentOn = viewControllerToPresentOn.presentedViewController; diff --git a/OneDriveSDK/Auth/ODBaseAuthProvider.m b/OneDriveSDK/Auth/ODBaseAuthProvider.m index 96abb64..2c33f58 100644 --- a/OneDriveSDK/Auth/ODBaseAuthProvider.m +++ b/OneDriveSDK/Auth/ODBaseAuthProvider.m @@ -47,10 +47,12 @@ - (instancetype)initWithServiceInfo:(ODServiceInfo *)serviceInfo - (void) authenticateWithViewController:(UIViewController *)viewController completion:(void (^)(NSError *error))completionHandler; { - // if the view controller is an ODAuthenticationViewController we just want to redirect to a new URL + // Get the view controller on the top of the stack + UIViewController *presentingViewController = [viewController childViewControllers][0]; + // if the view controller's child is an ODAuthenticationViewController we just want to redirect to a new URL // not push another view controller - if ([viewController respondsToSelector:@selector(redirectWithStartURL:endURL:success:)]){ - __block ODAuthenticationViewController *authViewController = (ODAuthenticationViewController *)viewController; + if (presentingViewController && [presentingViewController respondsToSelector:@selector(redirectWithStartURL:endURL:success:)]){ + __block ODAuthenticationViewController *authViewController = (ODAuthenticationViewController *)presentingViewController; NSURL *authURL = [self authURL]; [self.logger logWithLevel:ODLogDebug message:@"Authentication URL : %@", authURL]; [authViewController redirectWithStartURL:authURL @@ -58,15 +60,15 @@ - (void) authenticateWithViewController:(UIViewController *)viewController compl success:^(NSURL *endURL, NSError *error){ [self authorizationFlowCompletedWithURL:endURL error:error - presentingViewControlelr:authViewController + presentingViewControlelr:presentingViewController completion:completionHandler]; }]; } else { __block ODAuthenticationViewController *authViewController = [[ODAuthenticationViewController alloc] initWithStartURL:[self authURL] - endURL:[NSURL URLWithString:self.serviceInfo.redirectURL] - success:^(NSURL *endURL, NSError *error){ + endURL:[NSURL URLWithString:self.serviceInfo.redirectURL] + success:^(NSURL *endURL, NSError *error){ [self authorizationFlowCompletedWithURL:endURL error:error presentingViewControlelr:authViewController @@ -75,8 +77,14 @@ - (void) authenticateWithViewController:(UIViewController *)viewController compl }]; dispatch_async(dispatch_get_main_queue(), ^{ UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:authViewController]; - UIViewController *parentViewController = viewController; - [parentViewController presentViewController:navController animated:YES completion:nil]; + navController.modalPresentationStyle = viewController.modalPresentationStyle; + UIViewController *viewControllerToPresentOn = viewController; + while (viewControllerToPresentOn.presentedViewController) { + viewControllerToPresentOn = viewControllerToPresentOn.presentedViewController; + } + [viewControllerToPresentOn presentViewController:navController animated:YES completion:^{ + [authViewController loadInitialRequest]; + }]; }); } } @@ -88,7 +96,7 @@ - (void)authorizationFlowCompletedWithURL:(NSURL *)endURL { // Always remove the auth view when we finished loading. dispatch_async(dispatch_get_main_queue(), ^{ - [presentingViewController dismissViewControllerAnimated:YES completion:nil]; + [presentingViewController dismissViewControllerAnimated:NO completion:nil]; }); if (!error){ diff --git a/OneDriveSDK/Auth/ODBusinessAuthProvider.m b/OneDriveSDK/Auth/ODBusinessAuthProvider.m index 304a688..7ec0571 100644 --- a/OneDriveSDK/Auth/ODBusinessAuthProvider.m +++ b/OneDriveSDK/Auth/ODBusinessAuthProvider.m @@ -28,6 +28,7 @@ #import "ODAuthConstants.h" #import "ODAccountSession.h" #import "ODAADAccountBridge.h" +#import "ODAuthenticationViewController.h" @interface ODBusinessAuthProvider(){ @private @@ -41,6 +42,16 @@ @implementation ODBusinessAuthProvider - (void) authenticateWithViewController:(UIViewController*)viewController completion:(void (^)(NSError *error))completionHandler { self.authContext.parentController = viewController; + // If the disambiguation page is still being displayed remove it from the view + if (self.authContext.parentController){ + UIViewController *childViewController = [viewController childViewControllers][0]; + if (childViewController && [childViewController respondsToSelector:@selector(redirectWithStartURL:endURL:success:)]){ + self.authContext.parentController = viewController.presentingViewController; + dispatch_async(dispatch_get_main_queue(), ^{ + [childViewController dismissViewControllerAnimated:NO completion:nil]; + }); + } + } [self.authContext acquireTokenWithResource:self.serviceInfo.resourceId clientId:self.serviceInfo.appId redirectUri:[NSURL URLWithString:self.serviceInfo.redirectURL] diff --git a/OneDriveSDK/Extensions/ODClient+Authentication.m b/OneDriveSDK/Extensions/ODClient+Authentication.m index 6f16942..7abc915 100644 --- a/OneDriveSDK/Extensions/ODClient+Authentication.m +++ b/OneDriveSDK/Extensions/ODClient+Authentication.m @@ -198,7 +198,7 @@ - (void)authenticateWithAppConfig:(ODAppConfiguration *)appConfig [self authenticateWithAuthProvider:authProvider httpProvider:appConfig.httpProvider logger:appConfig.logger - viewController:presentedViewController + viewController:presentedViewController.parentViewController completion:completion]; } else { diff --git a/OneDriveSDK/OneDriveCoreSDK/Core/ODConstants.m b/OneDriveSDK/OneDriveCoreSDK/Core/ODConstants.m index 61a2b52..df5efe9 100644 --- a/OneDriveSDK/OneDriveCoreSDK/Core/ODConstants.m +++ b/OneDriveSDK/OneDriveCoreSDK/Core/ODConstants.m @@ -34,4 +34,4 @@ NSString *const ODHeaderContentType = @"Content-Type"; NSString *const ODHeaderApplicationJson = @"application/json"; NSString *const ODHeaderRespondAsync = @"respond-async"; -NSString *const ODSDKVersion = @"1.0.4"; +NSString *const ODSDKVersion = @"1.0.5"; diff --git a/README.md b/README.md index b216b17..26fda71 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# OneDrive iOS SDK +# Get started with the OneDrive SDK for iOS [![Build Status](https://travis-ci.org/OneDrive/onedrive-sdk-ios.svg?branch=master)](https://travis-ci.org/OneDrive/onedrive-sdk-ios) @@ -25,7 +25,7 @@ If you are targeting iOS 9 with XCode 7, you need to temporarily enable PFS exce To do this, add the following to your Info.plist : -``` +```xml NSAppTransportSecurity NSExceptionDomains @@ -66,7 +66,7 @@ These domains enable MSA and standard AAD authentication. It's possible that an **Warning** This it not the recommended approach and is only necessary if you wish to target all tenants that do not use standard AAD authentication and do not support Transport Layer Security v1.2. -``` +```xml NSAppTransportSecurity NSAllowArbitraryLoads diff --git a/docs/auth.md b/docs/auth.md index 664e0d0..5267bfb 100644 --- a/docs/auth.md +++ b/docs/auth.md @@ -5,7 +5,7 @@ To authenticate your app to use OneDrive, you only need to get a ODClient, which ## Simple authentication The easiest way to get authenticated is to call the clientWithCompletion method: -``` +```objc [ODClient clientWithCompletion:^(ODClient *client, NSError *error){ if (!error){ self.odClient = client; @@ -22,7 +22,7 @@ If there was an error in either of these steps, the error will be returned. If you want to invoke the UI, you can make a direct call to authenticatedClientWithCompletion: -``` +```objc [ODClient authenticatedClientWithCompletion:(ODClient *client, NSError *error){ if (!error){ self.odclient = client; @@ -35,7 +35,7 @@ This method will work like clientWithCompletion but it will not check the disk f If you already have accounts on the disk and want to select which account to use, you can call: -``` +```objc NSArray *accounts = [ODClient loadClients]; ``` @@ -43,19 +43,19 @@ This method will return an `NSArray` of ODClient objects that have been stored o If you want to load just the current account. You can also call: -``` +```objc ODClient *currentClient = [ODClient loadCurrentClient]; ``` You can set the current client by: -``` +```objc [ODClient setCurrentClient:]; ``` To load the client by the client's account id: -``` +```objc [ODClient loadClientWithAccountId:]; ``` @@ -65,7 +65,7 @@ To get a client's account id, use the `client.accountId` property on ODClient. To sign out you can call: -``` +```objc [currentClient signOutWithCompletion:^(NSError *error){ // This will remove any client information from disk. // An error will be passed back if an error occured during the sign out process. diff --git a/docs/collections.md b/docs/collections.md index c75c70e..d75b504 100644 --- a/docs/collections.md +++ b/docs/collections.md @@ -6,7 +6,7 @@ The OneDrive SDK for iOS allows you to work with item collections in OneDrive. To retrieve a collection, like a folder's children, you call getWithCompletion: -``` +```objc [[[[[odClient drive] items:] children] request] getWithCompletion: ^(ODCollection *children, ODChildrenCollectionRequest *nextRequest, NSError *error){ // Returns an ODCollection, @@ -29,7 +29,7 @@ The completion handler also takes an `ODChildrenCollectionRequest` called `nextR Some collections, like the children of a folder, can be changed. To add a folder to the children of an item you can call the addItem method: -``` +```objc ODItem *newFolder = [[ODIem alloc] init]; newFolder.name = ; newFolder.folder = [[ODFolder alloc] init]; @@ -42,7 +42,7 @@ newFolder.folder = [[ODFolder alloc] init]; To expand a collection, you call expand on the **CollectionRequest** object with the string you want to expand: -``` +```objc ODChildrenCollectionRequest *request = [[[[[[odClient] drive] items:] children] request] expand:@"thumbnails"]; [request getWithCompletion:^(ODCollection *children, ODChildrenCollectionRequest *nextRequest, NSError *error){ @@ -57,7 +57,7 @@ Some API calls will return collections with added properties. These properties To get the delta of an item you call: -``` +```objc [[[[[odClient drive] items:itemId] deltaWithToken:nil] request] executeWithCompletion:^(ODItemDeltaCollection *collection, ODItemDeltaRequest *nextReuqest, NSError *error){ diff --git a/docs/errors.md b/docs/errors.md index cd804f5..4fad976 100644 --- a/docs/errors.md +++ b/docs/errors.md @@ -12,7 +12,7 @@ There can be errors during the authentication process. If the error occurred dur You can easily check if an error is an authentication error by calling `[error IsAuthenticationError]`: -``` +```objc [ODClient clientWithCompletion:^(ODClient *client, NSError *error){ if (error && [error isAuthenticationError]){ // handle auth error @@ -28,7 +28,7 @@ See ODAuthConstants.h for a list of error codes during authentication. To retrie To check if an error is a client error, you can call `[error isClientError]` and `[error clientError]`, like this: -``` +```objc [[[[odClient drive] items:@"foo"] request] getWithCompletion:^(ODItem *item, NSError *error){ if (error && [error isClientError]){ [self handleClientError:[error clientError]]; @@ -40,7 +40,7 @@ When a client error arises there will be an ODError object stored in the userInf To check the code of an error, you can call the matches method on an error: -``` +```objc if ([odError matches:@"accessDenied"]){ // handle access denied error } diff --git a/docs/items.md b/docs/items.md index 0218ab8..4c2871f 100644 --- a/docs/items.md +++ b/docs/items.md @@ -16,7 +16,7 @@ Get an Item --------------- ### 1. By ID -``` +```objc [[[[odClient drive] items:] request] getWithCompletion:^(ODItem *item, NSError *error){ //Returns an ODItem object or an error if there was one. }]; @@ -24,7 +24,7 @@ Get an Item ### 2. By path -``` +```objc [[[[odClient root] itemByPath:@"Documents/Foo.txt"] request] getWithCompletion:^(ODItem *item, NSError *error){ //Returns an ODItem object or an error if there was one. }]; @@ -33,7 +33,7 @@ Get an Item Access an item by path from a folder item: -``` +```objc [[[[odClient drive] items:] itemByPath:@"relative/path/to/file.txt"] request] getWithCompletion:^(ODItem *item, NSError *error){ //Returns an ODItem object or an error if there was one. }]; @@ -42,7 +42,7 @@ Access an item by path from a folder item: Delete an Item --------------- -``` +```objc [[[[odClient drive] items:] request] deleteWithCompletion:^(NSError *error){ //Returns an error if there was one. }]; @@ -54,7 +54,7 @@ Get Children for an Item More info about collections [here](/docs/collections.md). -``` +```objc [[[[odClient drive] items:] children] getWithCompletion: ^(ODCollection *children, ODChilrenCollectionRequest *nextRequest, NSError *error){ // Returns an ODCollection, @@ -66,7 +66,7 @@ More info about collections [here](/docs/collections.md). Downloading and uploading contents ------------------------------ -``` +```objc ODItemContentRequest *request = [[[odClient drive] items:] contentRequest]; [request downloadWithCompletion:^(NSURL *filePath, NSURLResponse *urlResponse, NSError){ @@ -89,7 +89,7 @@ Moving and updating an Item -------------- To [move](https://dev.onedrive.com/items/move.htm) an item you must update its parent reference. -``` +```objc ODItem *updatedItem = [ODItem alloc] init]; updatedItem.id = ; updatedItem.parentReference = [ODItemReference alloc] init]; @@ -103,7 +103,7 @@ updatedItem.parentReference.id = ; To change an item's name or other property you could: -``` +```objc ODItem *updatedItem = [ODItem alloc] init]; updatedItem.id = ; updatedItem.name = @"New Item Name!"; @@ -119,7 +119,7 @@ Copy an Item --------------- Copying and item is an async action described [here](https://dev.onedrive.com/items/copy.htm). -``` +```objc ODItemReference *newParent = [ODItemReference alloc] init]; newParent.id = ; ODItemCopyRequest *copyRequest = [[[[odClient drive] items:] copyWithName:@"new item name" parentReference:newParent] request]; diff --git a/docs/overview.md b/docs/overview.md index 59c4da4..2247459 100644 --- a/docs/overview.md +++ b/docs/overview.md @@ -1,6 +1,6 @@ -# OneDrive iOS SDK +# OneDrive SDK for iOS overview -The OneDrive iOS SDK is designed to look just like the [OneDrive API](https://github.com/onedrive/onedrive-api-docs/). +The OneDrive SDK for iOS is designed to look just like the [OneDrive API](https://github.com/onedrive/onedrive-api-docs/). ## ODClient @@ -64,13 +64,13 @@ Once you have constructed the request you call the `request` method on the reque For an item you call: -``` +```objc ODItemRequest *itemRequest = [[[odClient drive] items:] request]; ``` All request builders have a `request` method that can generate a `ODRequest` object. Request objects may have different methods on them depending on the type of request. To get an item you call: -``` +```objc [itemRequest getWithCompletion:^(ODItem *item, NSError *error){ // This will make the network request and return the item // or an error if there was one @@ -78,7 +78,7 @@ All request builders have a `request` method that can generate a `ODRequest` obj ``` You could also chain this together with call above : -``` +```objc [[[[odClient drive] items:] request] getWithCompletion:^(ODItem *item, NSError *error){ }]; @@ -90,7 +90,7 @@ See [items](/docs/items.md) for more info on items and [errors](/docs/errors.md) If you only want to retrieve certain properties of a resource you can select them. Here's how to get only the names and ids of an item: -``` +```objc [[[[[odClient drive] items:] request] select:@"name,id"] getWithCompletion:^(ODItem *item, NSError *error){ // the item object will have nil properties for everything except name and id }]; @@ -98,7 +98,7 @@ If you only want to retrieve certain properties of a resource you can select the ``` To expand certain properties on resources you can call a similar expand method, like this: -``` +```objc [[[[[odClient drive] items:] request] expand:@"thumbnails"] getWithCompletion:^(ODItem *item, NSError *error){ // the item object will have a non nil thumbnails property if thumbnails exist. }];