Compare commits
14 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
c8ae154ba6 | |
|
|
5061d72908 | |
|
|
c28582cee5 | |
|
|
d6d65a57ea | |
|
|
9cdb1c8669 | |
|
|
c7548404dd | |
|
|
b7da2f2a8a | |
|
|
22635ef4b0 | |
|
|
c567b487bf | |
|
|
4ddf66e973 | |
|
|
c056db5ce9 | |
|
|
2f8be07617 | |
|
|
dfcb75709e | |
|
|
a1806eb420 |
|
|
@ -66,9 +66,13 @@ CocoaPods is a dependency manager for Objective-C, which automates and simplifie
|
|||
pod 'VK-ios-sdk'
|
||||
end
|
||||
|
||||
Then import project as module:
|
||||
Then import the project as module if your podfile contains `use_frameworks!` directive:
|
||||
|
||||
@import VK_ios_sdk;
|
||||
|
||||
Or import the main project header, if you're installing pods without `use_frameworks!` directive:
|
||||
|
||||
#import <VK-ios-sdk/VKSdk.h>
|
||||
|
||||
Installation with [Carthage](https://github.com/Carthage/Carthage)
|
||||
----------
|
||||
|
|
@ -196,7 +200,7 @@ Below we have listed some examples for several request types.
|
|||
|
||||
1) Plain request
|
||||
```
|
||||
VKRequest *audioReq = [[VKApi users] get];
|
||||
VKRequest *usersReq = [[VKApi users] get];
|
||||
```
|
||||
|
||||
2) Request with parameters
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
Pod::Spec.new do |s|
|
||||
s.name = "VK-ios-sdk"
|
||||
s.version = "1.4.2"
|
||||
s.version = "1.4.4"
|
||||
s.summary = "Library for working with VK."
|
||||
s.homepage = "https://github.com/VKCOM/vk-ios-sdk"
|
||||
s.license = 'MIT'
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@
|
|||
1ACA6509BAA3CEB2D5C3BA1D /* VKCaptchaViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1ACA608862B093D6D0F46BC4 /* VKCaptchaViewController.m */; };
|
||||
1ACA656AD2A705875E2C86DC /* VKApiBase.m in Sources */ = {isa = PBXBuildFile; fileRef = 1ACA628E1013456A0CB8D71E /* VKApiBase.m */; };
|
||||
1ACA65FFFA2849D789FFDB88 /* VKApiGroups.m in Sources */ = {isa = PBXBuildFile; fileRef = 1ACA62BE07D3E456A04ACE24 /* VKApiGroups.m */; };
|
||||
1ACA66450BE336D6F5AD4683 /* NSData+MD5.m in Sources */ = {isa = PBXBuildFile; fileRef = 1ACA628625B4301841232A88 /* NSData+MD5.m */; };
|
||||
1ACA664E3EC08CC26D0E2340 /* VKUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = 1ACA6F8866BE96889BB9DA68 /* VKUtil.m */; };
|
||||
1ACA66EB5F29CF88789B1D5F /* VKApiWall.m in Sources */ = {isa = PBXBuildFile; fileRef = 1ACA6D5C2E0E59A23C3D3B4C /* VKApiWall.m */; };
|
||||
1ACA68336BEF00F13DEDA870 /* VKUploadMessagesPhotoRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = 1ACA60EB8A19FBF44B2A0769 /* VKUploadMessagesPhotoRequest.m */; };
|
||||
|
|
@ -81,7 +80,6 @@
|
|||
F34670D61B8B7CCA003EF74B /* VKUploadImage.m in Sources */ = {isa = PBXBuildFile; fileRef = 1ACA6FA4664723004E33ADE4 /* VKUploadImage.m */; };
|
||||
F34670D71B8B7CD2003EF74B /* VKUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = 1ACA6F8866BE96889BB9DA68 /* VKUtil.m */; };
|
||||
F34670D81B8B7CD2003EF74B /* NSString+MD5.m in Sources */ = {isa = PBXBuildFile; fileRef = 1ACA6108D9F4E0C7644BAC52 /* NSString+MD5.m */; };
|
||||
F34670D91B8B7CD2003EF74B /* NSData+MD5.m in Sources */ = {isa = PBXBuildFile; fileRef = 1ACA628625B4301841232A88 /* NSData+MD5.m */; };
|
||||
F34670DA1B8B7CD2003EF74B /* OrderedDictionary.m in Sources */ = {isa = PBXBuildFile; fileRef = 1ACA69BCB967C1A6450F9935 /* OrderedDictionary.m */; };
|
||||
F34670DB1B8B7CD9003EF74B /* VKActivity.m in Sources */ = {isa = PBXBuildFile; fileRef = 1ACA6F9E65F7742733AB46DF /* VKActivity.m */; };
|
||||
F34670DC1B8B7CD9003EF74B /* VKAuthorizeController.m in Sources */ = {isa = PBXBuildFile; fileRef = 1ACA602BF516D3FC45609A2B /* VKAuthorizeController.m */; };
|
||||
|
|
@ -178,7 +176,6 @@
|
|||
F34671371B8B7D07003EF74B /* VKShareDialogController.h in Headers */ = {isa = PBXBuildFile; fileRef = 1ACA636E76F65CA58F05D4C9 /* VKShareDialogController.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
F34671381B8B7D07003EF74B /* VKSharedTransitioningObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 1ACA6A7961FA6DBB3C1530F9 /* VKSharedTransitioningObject.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
F34671391B8B7D07003EF74B /* VKUtil.h in Headers */ = {isa = PBXBuildFile; fileRef = 1ACA671427725230741603BC /* VKUtil.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
F346713A1B8B7D07003EF74B /* NSData+MD5.h in Headers */ = {isa = PBXBuildFile; fileRef = 1ACA60466E2608234660028D /* NSData+MD5.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
F346713B1B8B7D07003EF74B /* OrderedDictionary.h in Headers */ = {isa = PBXBuildFile; fileRef = 1ACA6CCE31EAF497A4030D24 /* OrderedDictionary.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
F346713C1B8B7D07003EF74B /* NSString+MD5.h in Headers */ = {isa = PBXBuildFile; fileRef = 1ACA6E07E9640D2B9D9B4831 /* NSString+MD5.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
F346713D1B8B7D07003EF74B /* VKUploadImage.h in Headers */ = {isa = PBXBuildFile; fileRef = 1ACA68CDC5C08713A61C5AD1 /* VKUploadImage.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
|
|
@ -335,7 +332,6 @@
|
|||
/* Begin PBXFileReference section */
|
||||
1ACA602BF516D3FC45609A2B /* VKAuthorizeController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VKAuthorizeController.m; sourceTree = "<group>"; };
|
||||
1ACA6041B183FB7781AC6F07 /* VKUploadMessagesPhotoRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VKUploadMessagesPhotoRequest.h; sourceTree = "<group>"; };
|
||||
1ACA60466E2608234660028D /* NSData+MD5.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSData+MD5.h"; sourceTree = "<group>"; };
|
||||
1ACA60549B5805BC010388F6 /* VKCaptchaViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VKCaptchaViewController.h; sourceTree = "<group>"; };
|
||||
1ACA6062CBB5C51999B6F516 /* VKObject.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VKObject.m; sourceTree = "<group>"; };
|
||||
1ACA608862B093D6D0F46BC4 /* VKCaptchaViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VKCaptchaViewController.m; sourceTree = "<group>"; };
|
||||
|
|
@ -351,7 +347,6 @@
|
|||
1ACA61B2E964393FB2431C30 /* VKOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VKOperation.h; sourceTree = "<group>"; };
|
||||
1ACA61F606614B473B1F8535 /* VKUploadWallPhotoRequest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VKUploadWallPhotoRequest.m; sourceTree = "<group>"; };
|
||||
1ACA624D02724AC703780337 /* VKResponse.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VKResponse.m; sourceTree = "<group>"; };
|
||||
1ACA628625B4301841232A88 /* NSData+MD5.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSData+MD5.m"; sourceTree = "<group>"; };
|
||||
1ACA628E1013456A0CB8D71E /* VKApiBase.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VKApiBase.m; sourceTree = "<group>"; };
|
||||
1ACA62BE07D3E456A04ACE24 /* VKApiGroups.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VKApiGroups.m; sourceTree = "<group>"; };
|
||||
1ACA62D0E659DB7778EF2633 /* VKImageParameters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VKImageParameters.h; sourceTree = "<group>"; };
|
||||
|
|
@ -654,8 +649,6 @@
|
|||
1ACA6F81E7D41D5219AB4B25 /* Utils */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
1ACA60466E2608234660028D /* NSData+MD5.h */,
|
||||
1ACA628625B4301841232A88 /* NSData+MD5.m */,
|
||||
1ACA6E07E9640D2B9D9B4831 /* NSString+MD5.h */,
|
||||
1ACA6108D9F4E0C7644BAC52 /* NSString+MD5.m */,
|
||||
1ACA6CCE31EAF497A4030D24 /* OrderedDictionary.h */,
|
||||
|
|
@ -832,7 +825,6 @@
|
|||
F34671191B8B7D07003EF74B /* VKLikes.h in Headers */,
|
||||
F34671021B8B7D07003EF74B /* VKHTTPClient.h in Headers */,
|
||||
F346713C1B8B7D07003EF74B /* NSString+MD5.h in Headers */,
|
||||
F346713A1B8B7D07003EF74B /* NSData+MD5.h in Headers */,
|
||||
F34671041B8B7D07003EF74B /* VKHTTPOperation.h in Headers */,
|
||||
F346710E1B8B7D07003EF74B /* VKRequestsScheduler.h in Headers */,
|
||||
F346710A1B8B7D07003EF74B /* VKOperation.h in Headers */,
|
||||
|
|
@ -1063,7 +1055,6 @@
|
|||
F346710F1B8B7D07003EF74B /* VKRequestsScheduler.m in Sources */,
|
||||
F34670F41B8B7D07003EF74B /* VKSdk.m in Sources */,
|
||||
F34671091B8B7D07003EF74B /* VKObject.m in Sources */,
|
||||
F34670D91B8B7CD2003EF74B /* NSData+MD5.m in Sources */,
|
||||
F346712A1B8B7D07003EF74B /* VKApiObjectArray.m in Sources */,
|
||||
F34670E51B8B7CE4003EF74B /* VKApiCaptcha.m in Sources */,
|
||||
);
|
||||
|
|
@ -1112,7 +1103,6 @@
|
|||
1ACA6F8C335233B3D05A0F49 /* VKActivity.m in Sources */,
|
||||
1ACA664E3EC08CC26D0E2340 /* VKUtil.m in Sources */,
|
||||
1ACA60B9FC0180221C536C9A /* NSString+MD5.m in Sources */,
|
||||
1ACA66450BE336D6F5AD4683 /* NSData+MD5.m in Sources */,
|
||||
8F99D6361C42C6010006DB03 /* VKApiDocs.m in Sources */,
|
||||
1ACA6C11956AB22CAA341CB1 /* OrderedDictionary.m in Sources */,
|
||||
1ACA656AD2A705875E2C86DC /* VKApiBase.m in Sources */,
|
||||
|
|
|
|||
|
|
@ -58,5 +58,4 @@ FOUNDATION_EXPORT const unsigned char VKSdkFrameworkVersionString[];
|
|||
#import <VKSdkFramework/VKJSONOperation.h>
|
||||
#import <VKSdkFramework/VKRequestsScheduler.h>
|
||||
#import <VKSdkFramework/VKSharedTransitioningObject.h>
|
||||
#import <VKSdkFramework/NSString+MD5.h>
|
||||
#import <VKSdkFramework/NSData+MD5.h>
|
||||
#import <VKSdkFramework/NSString+MD5.h>
|
||||
|
|
@ -36,8 +36,6 @@ static NSString *const DOUBLE_NAME = @"double";
|
|||
static NSString *const BOOL_NAME = @"bool";
|
||||
static NSString *const ID_NAME = @"id";
|
||||
|
||||
static NSMutableDictionary *classesProperties = nil;
|
||||
|
||||
static NSString *getPropertyType(objc_property_t property) {
|
||||
const char *type = property_getAttributes(property);
|
||||
NSString *typeString = [NSString stringWithUTF8String:type];
|
||||
|
|
@ -135,15 +133,18 @@ static NSString *getPropertyName(objc_property_t prop) {
|
|||
}
|
||||
|
||||
- (void)parse:(NSDictionary *)dict {
|
||||
static NSMutableDictionary *classesProperties = nil;
|
||||
static dispatch_semaphore_t classSemaphore = nil;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
classesProperties = [NSMutableDictionary dictionary];
|
||||
classSemaphore = dispatch_semaphore_create(1);
|
||||
});
|
||||
NSString *className = NSStringFromClass(self.class);
|
||||
__block NSMutableDictionary *propDict = nil;
|
||||
@synchronized (classesProperties) {
|
||||
propDict = [classesProperties objectForKey:className];
|
||||
}
|
||||
|
||||
dispatch_semaphore_wait(classSemaphore, DISPATCH_TIME_FOREVER);
|
||||
propDict = [classesProperties objectForKey:className];
|
||||
if (!propDict) {
|
||||
[self enumPropertiesWithBlock:^(VKPropertyHelper *helper, int totalProps) {
|
||||
if (!propDict)
|
||||
|
|
@ -153,10 +154,9 @@ static NSString *getPropertyName(objc_property_t prop) {
|
|||
if (!propDict) {
|
||||
propDict = [NSMutableDictionary new];
|
||||
}
|
||||
@synchronized (classesProperties) {
|
||||
classesProperties[className] = propDict;
|
||||
}
|
||||
classesProperties[className] = propDict;
|
||||
}
|
||||
dispatch_semaphore_signal(classSemaphore);
|
||||
NSMutableArray *warnings = PRINT_PARSE_DEBUG_INFO ? [NSMutableArray new] : nil;
|
||||
for (NSString *key in dict) {
|
||||
VKPropertyHelper *propHelper = propDict[key];
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@
|
|||
VKError *error = [VKError new];
|
||||
error.errorCode = VK_API_ERROR;
|
||||
error.errorReason = queryParams[@"error_reason"];
|
||||
#if __IPHONE_OS_VERSION_MAX_ALLOWED < __IPHONE_7_0
|
||||
#if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_8_0
|
||||
error.errorMessage = [queryParams[@"error_description"] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
|
||||
#else
|
||||
error.errorMessage = [queryParams[@"error_description"] stringByRemovingPercentEncoding];
|
||||
|
|
|
|||
|
|
@ -31,7 +31,8 @@
|
|||
|
||||
static VKHTTPClient *__clientInstance = nil;
|
||||
static NSString const *VK_API_URI = @"api.vk.com/method/";
|
||||
static NSString *const kVKMultipartFormBoundary = @"Boundary(======VK_SDK======)";
|
||||
static NSString const *kVKMultipartFormBoundaryPrefix = @"VK_SDK";
|
||||
|
||||
|
||||
@interface VKHTTPClient ()
|
||||
@property(readwrite, nonatomic, strong) NSMutableDictionary *defaultHeaders;
|
||||
|
|
@ -130,19 +131,20 @@ static NSString *const kVKMultipartFormBoundary = @"Boundary(======VK_SDK======)
|
|||
NSParameterAssert(![method isEqualToString:@"GET"] && ![method isEqualToString:@"HEAD"]);
|
||||
|
||||
NSMutableURLRequest *request = [self requestWithMethod:method path:path parameters:nil secure:YES];
|
||||
NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@", kVKMultipartFormBoundary];
|
||||
NSString *formBoundary = [NSString stringWithFormat:@"%@.boundary.%08x%08x", kVKMultipartFormBoundaryPrefix, arc4random(), arc4random()];
|
||||
NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@", formBoundary];
|
||||
[request addValue:contentType forHTTPHeaderField:@"Content-Type"];
|
||||
|
||||
NSMutableData *postbody = [NSMutableData data];
|
||||
for (NSUInteger i = 0; i < images.count; i++) {
|
||||
VKUploadImage *uploadImageObject = images[i];
|
||||
NSString *fileName = [NSString stringWithFormat:@"file%d", (int) (i + 1)];
|
||||
[postbody appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n", kVKMultipartFormBoundary] dataUsingEncoding:NSUTF8StringEncoding]];
|
||||
[postbody appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n", formBoundary] dataUsingEncoding:NSUTF8StringEncoding]];
|
||||
[postbody appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"%@\"; filename=\"%@.%@\"\r\n", fileName, fileName, [uploadImageObject.parameters fileExtension]] dataUsingEncoding:NSUTF8StringEncoding]];
|
||||
[postbody appendData:[[NSString stringWithFormat:@"Content-Type: %@\r\n\r\n", [uploadImageObject.parameters mimeType]] dataUsingEncoding:NSUTF8StringEncoding]];
|
||||
[postbody appendData:uploadImageObject.imageData];
|
||||
}
|
||||
[postbody appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n", kVKMultipartFormBoundary] dataUsingEncoding:NSUTF8StringEncoding]];
|
||||
[postbody appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n", formBoundary] dataUsingEncoding:NSUTF8StringEncoding]];
|
||||
[request setHTTPBody:postbody];
|
||||
return request;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -496,7 +496,7 @@ void vksdk_dispatch_on_main_queue_now(void(^block)(void)) {
|
|||
//Then we generate "request string" /method/{METHOD_NAME}?{GET_PARAMS}{POST_PARAMS}
|
||||
NSString *requestString = [NSString stringWithFormat:@"/method/%@?%@", _methodName, [paramsArray componentsJoinedByString:@"&"]];
|
||||
requestString = [requestString stringByAppendingString:token.secret];
|
||||
return [requestString MD5];
|
||||
return [requestString vks_md5];
|
||||
}
|
||||
|
||||
- (BOOL)processCommonError:(VKError *)error {
|
||||
|
|
|
|||
|
|
@ -1,29 +0,0 @@
|
|||
//
|
||||
// NSData+MD5.h
|
||||
//
|
||||
// Copyright (c) 2014
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
// this software and associated documentation files (the "Software"), to deal in
|
||||
// the Software without restriction, including without limitation the rights to
|
||||
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
// the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
// subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#import "NSData+MD5.h"
|
||||
|
||||
@interface NSData (MD5)
|
||||
|
||||
- (NSString *)MD5;
|
||||
|
||||
@end
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
//
|
||||
// NSData+MD5.m
|
||||
//
|
||||
// Copyright (c) 2014
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
// this software and associated documentation files (the "Software"), to deal in
|
||||
// the Software without restriction, including without limitation the rights to
|
||||
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
// the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
// subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#import <CommonCrypto/CommonDigest.h>
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@implementation NSData (MD5)
|
||||
|
||||
- (NSString *)MD5 {
|
||||
// Create byte array of unsigned chars
|
||||
unsigned char md5Buffer[CC_MD5_DIGEST_LENGTH];
|
||||
|
||||
// Create 16 byte MD5 hash value, store in buffer
|
||||
CC_MD5(self.bytes, (uint) self.length, md5Buffer);
|
||||
|
||||
// Convert unsigned char buffer to NSString of hex values
|
||||
NSMutableString *output = [NSMutableString stringWithCapacity:CC_MD5_DIGEST_LENGTH * 2];
|
||||
for (int i = 0; i < CC_MD5_DIGEST_LENGTH; i++)
|
||||
[output appendFormat:@"%02x", md5Buffer[i]];
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
@ -22,8 +22,8 @@
|
|||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface NSString (MD5)
|
||||
@interface NSString (VKSMD5)
|
||||
|
||||
- (NSString *)MD5;
|
||||
- (NSString *)vks_md5;
|
||||
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -24,9 +24,9 @@
|
|||
#import <Foundation/Foundation.h>
|
||||
#import "NSString+MD5.h"
|
||||
|
||||
@implementation NSString (MD5)
|
||||
@implementation NSString (VKSMD5)
|
||||
|
||||
- (NSString *)MD5 {
|
||||
- (NSString *)vks_md5 {
|
||||
// Create pointer to the string as UTF8
|
||||
const char *ptr = [self UTF8String];
|
||||
|
||||
|
|
|
|||
|
|
@ -47,11 +47,16 @@
|
|||
if ([number isKindOfClass:[NSNumber class]])
|
||||
return (NSNumber *) number;
|
||||
static dispatch_once_t onceToken;
|
||||
static dispatch_semaphore_t semaphore;
|
||||
static NSNumberFormatter *formatter;
|
||||
dispatch_once(&onceToken, ^{
|
||||
formatter = [[NSNumberFormatter alloc] init];
|
||||
semaphore = dispatch_semaphore_create(1);
|
||||
});
|
||||
return [formatter numberFromString:number];
|
||||
dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
|
||||
NSNumber *value = [formatter numberFromString:number];
|
||||
dispatch_semaphore_signal(semaphore);
|
||||
return value;
|
||||
}
|
||||
|
||||
+ (UIColor *)colorWithRGB:(NSInteger)rgb {
|
||||
|
|
@ -61,13 +66,13 @@
|
|||
static NSString *const kCharactersToBeEscapedInQueryString = @":/?&=;+!@#$()',*";
|
||||
|
||||
+ (NSString *)escapeString:(NSString *)value {
|
||||
#if __IPHONE_OS_VERSION_MAX_ALLOWED < __IPHONE_7_0
|
||||
#if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_9_0
|
||||
return (__bridge_transfer NSString *) CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (__bridge CFStringRef) value, NULL, (__bridge CFStringRef) kCharactersToBeEscapedInQueryString, CFStringConvertNSStringEncodingToEncoding(NSUTF8StringEncoding));
|
||||
#else
|
||||
static NSCharacterSet *charset = nil;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
charset = [NSCharacterSet URLHostAllowedCharacterSet];
|
||||
charset = [[NSCharacterSet characterSetWithCharactersInString:kCharactersToBeEscapedInQueryString] invertedSet];
|
||||
});
|
||||
return [value stringByAddingPercentEncodingWithAllowedCharacters:charset];
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -321,6 +321,11 @@ Enables or disables scheduling for requests
|
|||
*/
|
||||
+ (void)setSchedulerEnabled:(BOOL)enabled;
|
||||
|
||||
//custom sdk methods
|
||||
+ (void)forcedSetAccessToken:(VKAccessToken *)accessToken;
|
||||
|
||||
+ (void)forcedWakeUpSession;
|
||||
|
||||
// Deny allocating more SDK
|
||||
+ (instancetype)alloc NS_UNAVAILABLE;
|
||||
|
||||
|
|
|
|||
|
|
@ -225,9 +225,14 @@ static NSString *VK_ACCESS_TOKEN_DEFAULTS_KEY = @"VK_ACCESS_TOKEN_DEFAULTS_KEY_D
|
|||
if (instance.presentedSafariViewController) {
|
||||
UIViewController *safariVC = instance.presentedSafariViewController;
|
||||
[safariVC vks_viewControllerWillDismiss];
|
||||
[safariVC.presentingViewController dismissViewControllerAnimated:YES completion:^{
|
||||
void (^dismissBlock)() = ^{
|
||||
[safariVC vks_viewControllerDidDismiss];
|
||||
}];
|
||||
};
|
||||
if (safariVC.isBeingDismissed) {
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5f * NSEC_PER_SEC)), dispatch_get_main_queue(), dismissBlock);
|
||||
} else {
|
||||
[safariVC.presentingViewController dismissViewControllerAnimated:YES completion:dismissBlock];
|
||||
}
|
||||
instance.presentedSafariViewController = nil;
|
||||
}
|
||||
};
|
||||
|
|
@ -372,7 +377,7 @@ static NSString *VK_ACCESS_TOKEN_DEFAULTS_KEY = @"VK_ACCESS_TOKEN_DEFAULTS_KEY_D
|
|||
}
|
||||
|
||||
+ (void)wakeUpSession:(NSArray *)permissions completeBlock:(void (^)(VKAuthorizationState, NSError *error))wakeUpBlock {
|
||||
VKAccessToken *token = [self accessToken] ?: [VKAccessToken savedToken:VK_ACCESS_TOKEN_DEFAULTS_KEY];
|
||||
VKAccessToken *token = [self actualToken];
|
||||
VKSdk *instance = [self instance];
|
||||
if (!token || token.isExpired) {
|
||||
[instance resetSdkState];
|
||||
|
|
@ -447,6 +452,19 @@ static NSString *VK_ACCESS_TOKEN_DEFAULTS_KEY = @"VK_ACCESS_TOKEN_DEFAULTS_KEY_D
|
|||
[[VKRequestsScheduler instance] setEnabled:enabled];
|
||||
}
|
||||
|
||||
+ (void)forcedSetAccessToken:(VKAccessToken *)accessToken {
|
||||
self.accessToken = accessToken;
|
||||
}
|
||||
|
||||
+ (void)forcedWakeUpSession {
|
||||
VKSdk *instance = [self instance];
|
||||
instance.accessToken = [self actualToken];
|
||||
instance.authState = VKAuthorizationAuthorized;
|
||||
}
|
||||
|
||||
+ (VKAccessToken *)actualToken {
|
||||
return [self accessToken] ?: [VKAccessToken savedToken:VK_ACCESS_TOKEN_DEFAULTS_KEY];
|
||||
}
|
||||
|
||||
#pragma mark - Instance methods
|
||||
|
||||
|
|
|
|||
|
|
@ -20,5 +20,5 @@
|
|||
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#define VK_SDK_VERSION @"1.4.2"
|
||||
#define VK_SDK_VERSION @"1.4.4"
|
||||
#define VK_SDK_API_VERSION @"5.40"
|
||||
|
|
|
|||
|
|
@ -951,10 +951,11 @@ static const CGFloat kAttachmentsViewSize = 100.0f;
|
|||
}
|
||||
|
||||
- (void)close:(id)sender {
|
||||
if (self.parent.completionHandler != NULL) {
|
||||
self.parent.completionHandler(self.parent, VKShareDialogControllerResultCancelled);
|
||||
__strong typeof(self.parent) parent = self.parent;
|
||||
if (parent.completionHandler != NULL) {
|
||||
parent.completionHandler(parent, VKShareDialogControllerResultCancelled);
|
||||
}
|
||||
if (self.parent.dismissAutomatically) {
|
||||
if (parent.dismissAutomatically) {
|
||||
[self.navigationController.presentingViewController dismissViewControllerAnimated:YES completion:nil];
|
||||
}
|
||||
}
|
||||
|
|
@ -976,8 +977,9 @@ static const CGFloat kAttachmentsViewSize = 100.0f;
|
|||
}
|
||||
[attachStrings addObject:attach.attachmentString];
|
||||
}
|
||||
if (self.parent.shareLink) {
|
||||
[attachStrings addObject:[self.parent.shareLink.link absoluteString]];
|
||||
__strong typeof(self.parent) parent = self.parent;
|
||||
if (parent.shareLink) {
|
||||
[attachStrings addObject:[parent.shareLink.link absoluteString]];
|
||||
}
|
||||
|
||||
VKRequest *post = [[VKApi wall] post:@{VK_API_MESSAGE : textView.text ?: @"",
|
||||
|
|
@ -992,12 +994,12 @@ static const CGFloat kAttachmentsViewSize = 100.0f;
|
|||
[post executeWithResultBlock:^(VKResponse *response) {
|
||||
NSNumber *post_id = VK_ENSURE_NUM(response.json[@"post_id"]);
|
||||
if (post_id) {
|
||||
self.parent.postId = [NSString stringWithFormat:@"%@_%@", [VKSdk accessToken].userId, post_id];
|
||||
parent.postId = [NSString stringWithFormat:@"%@_%@", [VKSdk accessToken].userId, post_id];
|
||||
}
|
||||
if (self.parent.completionHandler != NULL) {
|
||||
self.parent.completionHandler(self.parent, VKShareDialogControllerResultDone);
|
||||
if (parent.completionHandler != NULL) {
|
||||
parent.completionHandler(parent, VKShareDialogControllerResultDone);
|
||||
}
|
||||
if (self.parent.dismissAutomatically) {
|
||||
if (parent.dismissAutomatically) {
|
||||
[self.navigationController.presentingViewController dismissViewControllerAnimated:YES completion:nil];
|
||||
}
|
||||
} errorBlock:^(NSError *error) {
|
||||
|
|
@ -1006,7 +1008,7 @@ static const CGFloat kAttachmentsViewSize = 100.0f;
|
|||
textView.editable = YES;
|
||||
[textView becomeFirstResponder];
|
||||
|
||||
#if __IPHONE_OS_VERSION_MAX_ALLOWED < __IPHONE_7_0
|
||||
#if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_8_0
|
||||
[[[UIAlertView alloc] initWithTitle:nil message:VKLocalizedString(@"ErrorWhilePosting") delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] show];
|
||||
#else
|
||||
UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:VKLocalizedString(@"ErrorWhilePosting") preferredStyle:UIAlertControllerStyleAlert];
|
||||
|
|
@ -1068,7 +1070,8 @@ static const CGFloat kAttachmentsViewSize = 100.0f;
|
|||
self.attachmentsArray = [NSMutableArray new];
|
||||
VKShareDialogView *shareDialogView = (VKShareDialogView *) self.view;
|
||||
//Attach and upload images
|
||||
for (VKUploadImage *img in self.parent.uploadImages) {
|
||||
__strong typeof(self.parent) parent = self.parent;
|
||||
for (VKUploadImage *img in parent.uploadImages) {
|
||||
if (!(img.imageData || img.sourceImage)) continue;
|
||||
CGSize size = img.sourceImage.size;
|
||||
size = CGSizeMake(MAX(floorf(size.width * maxHeight / size.height), 50.f), maxHeight);
|
||||
|
|
@ -1097,9 +1100,9 @@ static const CGFloat kAttachmentsViewSize = 100.0f;
|
|||
attach.uploadingRequest = uploadRequest;
|
||||
}
|
||||
|
||||
if (self.parent.vkImages.count) {
|
||||
if (parent.vkImages.count) {
|
||||
NSMutableDictionary *attachById = [NSMutableDictionary new];
|
||||
for (NSString *photo in self.parent.vkImages) {
|
||||
for (NSString *photo in parent.vkImages) {
|
||||
NSAssert([photo isKindOfClass:[NSString class]], @"vkImages must contains only string photo ids");
|
||||
if (attachById[photo]) continue;
|
||||
VKUploadingAttachment *attach = [VKUploadingAttachment new];
|
||||
|
|
@ -1110,7 +1113,7 @@ static const CGFloat kAttachmentsViewSize = 100.0f;
|
|||
attachById[photo] = attach;
|
||||
}
|
||||
|
||||
VKRequest *req = [VKRequest requestWithMethod:@"photos.getById" parameters:@{@"photos" : [self.parent.vkImages componentsJoinedByString:@","], @"photo_sizes" : @1} modelClass:[VKPhotoArray class]];
|
||||
VKRequest *req = [VKRequest requestWithMethod:@"photos.getById" parameters:@{@"photos" : [parent.vkImages componentsJoinedByString:@","], @"photo_sizes" : @1} modelClass:[VKPhotoArray class]];
|
||||
[req executeWithResultBlock:^(VKResponse *res) {
|
||||
VKPhotoArray *photos = res.parsedModel;
|
||||
NSArray *requiredSizes = @[@"p", @"q", @"m"];
|
||||
|
|
@ -1167,8 +1170,8 @@ static const CGFloat kAttachmentsViewSize = 100.0f;
|
|||
[self.attachmentsScrollView reloadData];
|
||||
[shareDialogView setNeedsLayout];
|
||||
|
||||
if (self.parent.shareLink) {
|
||||
[shareDialogView setShareLink:self.parent.shareLink];
|
||||
if (parent.shareLink) {
|
||||
[shareDialogView setShareLink:parent.shareLink];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue