8 Commits
Author SHA1 Message Date
wushenghua 85c53f07b0 修改pod文件 2016-01-21 09:34:43 +08:00
wushenghua dddd9cc42b 修改部分bug 2016-01-21 09:33:57 +08:00
wushenghua 3182a46058 xiugaipeizhi 2016-01-21 09:16:48 +08:00
wushenghua 9bcd19605a 修改 2016-01-21 08:44:55 +08:00
wushenghua 1edd47447d 修改pod文件 2016-01-21 08:39:56 +08:00
wushenghua dea9306931 修改 2016-01-20 18:16:28 +08:00
wushenghua e0bbd64444 修改细节 2016-01-20 17:14:02 +08:00
wushenghua 3b3db7397a 修改pod文件 2016-01-20 16:28:16 +08:00
18 changed files with 339 additions and 306 deletions
Vendored
BIN
View File
Binary file not shown.
-2
View File
@@ -2,14 +2,12 @@ platform :ios, '6.0'
pod 'Reachability'
pod 'SBJson'
pod 'SDWebImage'
pod 'DTCoreText'
pod 'STableViewController'
pod 'MBProgressHUD'
pod 'AFNetworking'
pod 'Mantle'
pod 'Godzippa'
pod 'EGOCache'
pod 'SecureUDID'
pod 'MJRefresh'
pod 'SVWebViewController'
pod 'ReactiveCocoa'
+151
View File
@@ -0,0 +1,151 @@
#
# Be sure to run `pod spec lint WlianWorld.podspec' to ensure this is a
# valid spec and to remove all comments including this before submitting the spec.
#
# To learn more about Podspec attributes see http://docs.cocoapods.org/specification.html
# To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/
#
Pod::Spec.new do |s|
# ――― Spec Metadata ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# These will help people to find your library, and whilst it
# can feel like a chore to fill in it's definitely to your advantage. The
# summary should be tweet-length, and the description more in depth.
#
s.name = "WlianWorld"
s.version = "0.0.1"
s.summary = "微连天下1"
# This description is used to generate tags and improve search results.
# * Think: What does it do? Why did you write it? What is the focus?
# * Try to keep it short, snappy and to the point.
# * Write the description between the DESC delimiters below.
# * Finally, don't worry about the indent, CocoaPods strips it!
s.homepage = "https://github.com/wu736139669"
# s.screenshots = "www.example.com/screenshots_1.gif", "www.example.com/screenshots_2.gif"
# ――― Spec License ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# Licensing your code is important. See http://choosealicense.com for more info.
# CocoaPods will detect a license file if there is a named LICENSE*
# Popular ones are 'MIT', 'BSD' and 'Apache License, Version 2.0'.
#
# s.license = "MIT (example)"
s.license = { :type => "MIT", :file => "LICENSE" }
# ――― Author Metadata ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# Specify the authors of the library, with email addresses. Email addresses
# of the authors are extracted from the SCM log. E.g. $ git log. CocoaPods also
# accepts just a name if you'd rather not provide an email address.
#
# Specify a social_media_url where others can refer to, for example a twitter
# profile URL.
#
s.author = { "wushenghua" => "https://github.com/wu736139669" }
# Or just: s.author = "wushenghua"
# s.authors = { "wushenghua" => "https://github.com/wu736139669" }
# s.social_media_url = "http://twitter.com/wushenghua"
# ――― Platform Specifics ――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# If this Pod runs only on iOS or OS X, then specify the platform and
# the deployment target. You can optionally include the target after the platform.
#
s.platform = :ios
s.platform = :ios, "7.0"
# When using multiple platforms
# s.ios.deployment_target = "5.0"
# s.osx.deployment_target = "10.7"
# s.watchos.deployment_target = "2.0"
# s.tvos.deployment_target = "9.0"
# ――― Source Location ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# Specify the location from where the source should be retrieved.
# Supports git, hg, bzr, svn and HTTP.
#
s.source = { :git => "https://github.com/wu736139669/WlianWorld.git", :tag => "0.0.1" }
# ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# CocoaPods is smart about how it includes source code. For source files
# giving a folder will include any swift, h, m, mm, c & cpp files.
# For header files it will include any header in the folder.
# Not including the public_header_files will make all headers public.
#
s.source_files = 'WlianWorld/Model/*.{h,m}','WlianWorld/Util/**/*.{h,m}','WlianWorld/View/*.{h,m}','WlianWorld/ViewModel/*.{h,m}','WlianWorld/Config/*.{h,m}'
# s.exclude_files = "Classes/Exclude"
s.resources = 'WlianWorld/View/*.xib','WlianWorld/Resource/*'
s.prefix_header_file = 'WlianWorld/PrefixHeader.pch'
s.frameworks = "UIKit"
s.dependency 'Mantle'
s.dependency 'AFNetworking', '~> 2.5.4'
# s.dependency 'DTCoreText', '~>1.6.17'
s.dependency 'EGOCache'
s.dependency 'Godzippa', '~>1.1.0'
s.dependency 'MBProgressHUD', '~>0.9.2'
s.dependency 'MJRefresh', '~>3.1.0'
s.dependency 'Reachability', '~>3.2'
s.dependency 'ReactiveCocoa', '~>2.5'
s.dependency 'SDWebImage', '~>3.7.4'
# s.dependency 'SecureUDID', '~>1.1'
s.dependency 'STableViewController', '~>0.0.1'
s.dependency 'SVWebViewController', '~>1.0'
s.dependency 'SBJson', '~>4.0.2'
# ――― Resources ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# A list of resources included with the Pod. These are copied into the
# target bundle with a build phase script. Anything else will be cleaned.
# You can preserve files from being cleaned, please don't preserve
# non-essential files like tests, examples and documentation.
#
# s.resource = "icon.png"
# s.resources = "Resources/*.png"
# s.preserve_paths = "FilesToSave", "MoreFilesToSave"
# ――― Project Linking ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# Link your library with frameworks, or libraries. Libraries do not include
# the lib prefix of their name.
#
# s.framework = "SomeFramework"
# s.frameworks = "SomeFramework", "AnotherFramework"
# s.library = "iconv"
# s.libraries = "iconv", "xml2"
# ――― Project Settings ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
#
# If your library depends on compiler flags you can set them in the xcconfig hash
# where they will only apply to your library. If you depend on other Podspecs
# you can include multiple dependencies to ensure it works.
s.requires_arc = true
# s.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" }
# s.dependency "JSONKit", "~> 1.4"
end
-45
View File
@@ -1,45 +0,0 @@
{
"name": "WlianWorld",
"version": "1.0",
"summary": "WlianWorld",
"description": "WlianWorld, 微连天下",
"homepage": "http://www.xiaoyu.com",
"license": "MIT",
"authors": {
"haha": "736139669@qq.com"
},
"source": {
"git": "git@github.com:wu736139669/WlianWorld.git"
},
"platforms": {
"ios": "7.0"
},
"source_files": [
"WlianWorld/Model/*.{h,m}",
"WlianWorld/Util/*/*.{h,m}",
"WlianWorld/View/*/*/*.{h,m}",
"WlianWorld/Config/*/*/*/*.{h,m}",
"WlianWorld/ViewModel/*.{h,m}"
],
"resources": [
"WlianWorld/Resources/*.{xib,json,png,jpg,gif,js}",
],
"requires_arc": true,
"dependencies": {
"Reachability":[],
"SDWebImage":[],
"DTCoreText":[],
"STableViewController":[],
"MBProgressHUD":[],
"AFNetworking":[],
"Mantle":[],
"Godzippa":[],
"SecureUDID":[],
"EGOCache":[],
"MJRefresh":[],
"SVWebViewController":[],
"ReactiveCocoa":[],
"IQKeyboardManager":[],
}
}
+10
View File
@@ -534,6 +534,10 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 1EA287A0584796EB45606160 /* Pods.debug.xcconfig */;
buildSettings = {
ARCHS = (
"$(ARCHS_STANDARD)",
"$(ARCHS_STANDARD_INCLUDING_64_BIT)",
);
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
GCC_PREFIX_HEADER = WlianWorld/PrefixHeader.pch;
INFOPLIST_FILE = WlianWorld/Info.plist;
@@ -541,6 +545,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = ash.WlianWorld;
PRODUCT_NAME = "$(TARGET_NAME)";
VALID_ARCHS = "arm64 armv7 armv7s";
};
name = Debug;
};
@@ -548,6 +553,10 @@
isa = XCBuildConfiguration;
baseConfigurationReference = E85CC6782134D0C21F8B26CC /* Pods.release.xcconfig */;
buildSettings = {
ARCHS = (
"$(ARCHS_STANDARD)",
"$(ARCHS_STANDARD_INCLUDING_64_BIT)",
);
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
GCC_PREFIX_HEADER = WlianWorld/PrefixHeader.pch;
INFOPLIST_FILE = WlianWorld/Info.plist;
@@ -555,6 +564,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = ash.WlianWorld;
PRODUCT_NAME = "$(TARGET_NAME)";
VALID_ARCHS = "arm64 armv7 armv7s";
};
name = Release;
};
@@ -3,70 +3,6 @@
type = "0"
version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "WlianWorld/Model/BaseWLService.m"
timestampString = "469096535.078965"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "69"
endingLineNumber = "69"
landmarkName = "+requireWithGetWithProperty:"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "WlianWorld/Model/BaseWLService.m"
timestampString = "469096536.720861"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "67"
endingLineNumber = "67"
landmarkName = "+requireWithGetWithProperty:"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "WlianWorld/Model/BaseWLService.m"
timestampString = "469096539.285181"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "74"
endingLineNumber = "74"
landmarkName = "+requireWithGetWithProperty:"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "WlianWorld/Model/LoginModel.m"
timestampString = "469434914.778453"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "46"
endingLineNumber = "46"
landmarkName = "-loginSignalWithAccount:withPassword:"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
@@ -96,9 +96,9 @@
"scale" : "2x"
},
{
"idiom" : "car",
"size" : "120x120",
"scale" : "1x"
"idiom" : "ipad",
"size" : "83.5x83.5",
"scale" : "2x"
},
{
"size" : "24x24",
@@ -153,6 +153,11 @@
"scale" : "2x",
"role" : "quickLook",
"subtype" : "42mm"
},
{
"idiom" : "car",
"size" : "120x120",
"scale" : "1x"
}
],
"info" : {
+7 -8
View File
@@ -7,28 +7,27 @@
//
#import "BaseAPIClient.h"
#import "Common.h"
@implementation BaseAPIClient
+ (instancetype)sharedClient
{
static BaseAPIClient *_sharedClient = nil;
static BaseAPIClient* _sharedClient = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
_sharedClient = [[BaseAPIClient alloc] initWithBaseURL:[NSURL URLWithString:[self getApiBaseString]]];
_sharedClient.securityPolicy = [AFSecurityPolicy policyWithPinningMode:AFSSLPinningModeNone];
[_sharedClient.requestSerializer setValue:@"text/html" forHTTPHeaderField:@"Content-Type"];
_sharedClient.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html"];
});
return _sharedClient;
}
+ (NSString *)getApiBaseString
+ (NSString*)getApiBaseString
{
return WL_DEV_API_URL;
return WL_DEV_API_URL;
}
@end
+4 -5
View File
@@ -7,11 +7,10 @@
//
#import <Foundation/Foundation.h>
@interface BaseModel : MTLModel <MTLJSONSerializing>
@interface BaseModel : MTLModel<MTLJSONSerializing>
@property (nonatomic,strong)NSString* title;
@property (nonatomic,readonly)NSString* errorCode;
@property (nonatomic,readonly)NSString* errorMessage;
@property (nonatomic, strong) NSString* title;
@property (nonatomic, readonly) NSString* errorCode;
@property (nonatomic, readonly) NSString* errorMessage;
@end
+27 -26
View File
@@ -7,40 +7,41 @@
//
#import "BaseModel.h"
@implementation BaseModel
+ (NSDictionary *)JSONKeyPathsByPropertyKey {
+ (NSDictionary*)JSONKeyPathsByPropertyKey
{
return @{
// @"errCode": @"ret",
@"errorCode": @"errorCode",
@"errorMessage": @"errorMessage",
};
// @"errCode": @"ret",
@"errorCode" : @"errorCode",
@"errorMessage" : @"errorMessage",
};
}
+ (NSValueTransformer *)errorCodeJSONTransformer {
return [MTLValueTransformer transformerUsingForwardBlock:^id(id value,BOOL *success, NSError *__autoreleasing *error) {
NSNumber *num = value;
NSString *tempStr = [NSString stringWithFormat:@"%@", num];
+ (NSValueTransformer*)errorCodeJSONTransformer
{
return [MTLValueTransformer transformerUsingForwardBlock:^id(id value, BOOL* success, NSError* __autoreleasing* error) {
NSNumber* num = value;
NSString* tempStr = [NSString stringWithFormat:@"%@", num];
return tempStr;
} reverseBlock:^id(id value,BOOL *success, NSError *__autoreleasing *error) {
NSString *tempStr = value;
NSNumber *tempNum = @(tempStr.integerValue);
return tempNum;
}];
}
reverseBlock:^id(id value, BOOL* success, NSError* __autoreleasing* error) {
NSString* tempStr = value;
NSNumber* tempNum = @(tempStr.integerValue);
return tempNum;
}];
}
- (instancetype)initWithDictionary:(NSDictionary *)dictionaryValue error:(NSError **)error
- (instancetype)initWithDictionary:(NSDictionary*)dictionaryValue error:(NSError**)error
{
self = [super initWithDictionary:dictionaryValue error:error];
if (self != nil)
{
if (self != nil) {
}
return self;
}
+49 -58
View File
@@ -6,95 +6,86 @@
// Copyright © 2015年 ash. All rights reserved.
//
#import "BaseWLService.h"
#import "BaseEntity.h"
#import "BaseWLService.h"
#import "Common.h"
#import "MTLJSONAdapter.h"
#import "NSData+Godzippa.h"
#import "EGOCache.h"
#import "BaseAPIClient.h"
#import <EGOCache/EGOCache.h>
@implementation BaseWLService
+ (void)saveCacheWithAPIKey:(NSString *)apiKey property:(BaseEntity *)proper data:(id)tweet{
+ (void)saveCacheWithAPIKey:(NSString*)apiKey property:(BaseEntity*)proper data:(id)tweet
{
if (proper.isCache) {
SEL selector = NSSelectorFromString(@"errCode");
IMP imp = [tweet methodForSelector:selector];
NSString* (*func)(id, SEL) = (void *)imp;
NSString *tmpErrCode = func(tweet, selector);
NSString* (*func)(id, SEL) = (void*)imp;
NSString* tmpErrCode = func(tweet, selector);
DLog(@"%@", tmpErrCode);
if (([tmpErrCode isKindOfClass:[NSString class]] && [tmpErrCode isEqualToString:@"0"] ) || ([tmpErrCode isKindOfClass:[NSNumber class]] && [tmpErrCode integerValue]==0)) {
if (([tmpErrCode isKindOfClass:[NSString class]] && [tmpErrCode isEqualToString:@"0"]) || ([tmpErrCode isKindOfClass:[NSNumber class]] && [tmpErrCode integerValue] == 0)) {
[[EGOCache globalCache] setObject:tweet forKey:apiKey];
}
}
}
+ (void)responseFromCacheWithAPIKey:(NSString *)apiKey property:(BaseEntity *)proper completionBlock:(id)subscriber{
+ (void)responseFromCacheWithAPIKey:(NSString*)apiKey property:(BaseEntity*)proper completionBlock:(id)subscriber
{
if (proper.isCache && [[EGOCache globalCache] hasCacheForKey:apiKey]) {
[subscriber sendNext:[[EGOCache globalCache] objectForKey:apiKey]];
[subscriber sendCompleted];
}
}
+(RACSignal*)requireWithProperty:(BaseEntity *)proper
+ (RACSignal*)requireWithProperty:(BaseEntity*)proper
{
// if (proper.requireType == HTTPRequestTypeWithGET) {
// return [self requireWithGetWithProperty:proper];
// }
// return nil;
// if (proper.requireType == HTTPRequestTypeWithGET) {
// return [self requireWithGetWithProperty:proper];
// }
// return nil;
return [self requireWithGetWithProperty:proper];
}
+(RACSignal*)requireWithGetWithProperty:(BaseEntity*)proper
+ (RACSignal*)requireWithGetWithProperty:(BaseEntity*)proper
{
NSString *apiKey = proper.cacheKey;
if (proper.pro && proper.pro[@"page"])
{
apiKey = [apiKey stringByAppendingFormat:@"%@",proper.pro[@"page"]];
NSString* apiKey = proper.cacheKey;
if (proper.pro && proper.pro[@"page"]) {
apiKey = [apiKey stringByAppendingFormat:@"%@", proper.pro[@"page"]];
}
return [[RACSignal createSignal:^RACDisposable *(id<RACSubscriber> subscriber) {
return [[RACSignal createSignal:^RACDisposable*(id<RACSubscriber> subscriber) {
[[BaseAPIClient sharedClient] GET:[proper reqURL]
parameters: [proper encodePro]
success:^(AFHTTPRequestOperation * __unused task, id json) {
DLog(@"%@", json);
if(json)
{
NSError *error = nil;
id tweet = [MTLJSONAdapter modelOfClass:[proper.responesOBJ class] fromJSONDictionary:json error:&error];
[subscriber sendNext:tweet];
[subscriber sendCompleted];
[self saveCacheWithAPIKey:apiKey property:proper data:tweet];
}
else
{
[subscriber sendNext:nil];
[subscriber sendCompleted];
}
}
failure:^(AFHTTPRequestOperation *__unused task, NSError *error) {
DLog(@"%@", error.description);
[subscriber sendError:error];
[self responseFromCacheWithAPIKey:apiKey property:proper completionBlock:subscriber];
}];
parameters:[proper encodePro]
success:^(AFHTTPRequestOperation* __unused task, id json) {
DLog(@"%@", json);
if (json) {
NSError* error = nil;
id tweet = [MTLJSONAdapter modelOfClass:[proper.responesOBJ class] fromJSONDictionary:json error:&error];
[subscriber sendNext:tweet];
[subscriber sendCompleted];
[self saveCacheWithAPIKey:apiKey property:proper data:tweet];
}
else {
[subscriber sendNext:nil];
[subscriber sendCompleted];
}
}
failure:^(AFHTTPRequestOperation* __unused task, NSError* error) {
DLog(@"%@", error.description);
[subscriber sendError:error];
[self responseFromCacheWithAPIKey:apiKey property:proper completionBlock:subscriber];
}];
return [RACDisposable disposableWithBlock:^{
}];
}] replayLazily];
}] replayLazily];
}
@end
+8 -8
View File
@@ -6,17 +6,17 @@
// Copyright © 2015年 ash. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "BaseModel.h"
#import <ReactiveCocoa/ReactiveCocoa.h>
@interface LoginModel : BaseModel
@property (nonatomic,readonly) NSNumber* status;
@property (nonatomic, readonly) NSString *msg;
@property (nonatomic,readonly) NSString* userid;
@property (nonatomic, readonly) NSString *username;
@property (nonatomic,readonly) NSString* shopid;
@property (nonatomic, readonly) NSString *shopname;
@property (nonatomic,readonly) NSString* token;
@property (nonatomic, readonly) NSNumber* status;
@property (nonatomic, readonly) NSString* msg;
@property (nonatomic, readonly) NSString* userid;
@property (nonatomic, readonly) NSString* username;
@property (nonatomic, readonly) NSString* shopid;
@property (nonatomic, readonly) NSString* shopname;
@property (nonatomic, readonly) NSString* token;
- (RACSignal*)loginSignalWithAccount:(NSString*)account withPassword:(NSString*)password;
@end
+14 -14
View File
@@ -6,12 +6,14 @@
// Copyright © 2015年 ash. All rights reserved.
//
#import "BaseEntity.h"
#import "BaseWLService.h"
#import "LoginModel.h"
#import "LoginViewModel.h"
@implementation LoginModel
+ (NSDictionary *)JSONKeyPathsByPropertyKey {
+ (NSDictionary*)JSONKeyPathsByPropertyKey
{
NSMutableDictionary* dic = [NSMutableDictionary dictionaryWithDictionary:[super JSONKeyPathsByPropertyKey]];
[dic setObject:@"info.msg" forKey:@"msg"];
[dic setObject:@"info.status" forKey:@"status"];
@@ -22,34 +24,32 @@
[dic setObject:@"info.userinfo.token" forKey:@"token"];
return dic;
}
- (instancetype)initWithDictionary:(NSDictionary *)dictionaryValue error:(NSError **)error
- (instancetype)initWithDictionary:(NSDictionary*)dictionaryValue error:(NSError**)error
{
self = [super initWithDictionary:dictionaryValue error:error];
if (self != nil)
{
if (self != nil) {
}
return self;
}
- (instancetype)init
{
self = [super init];
if (self)
{
if (self) {
}
return self;
}
-(RACSignal*)loginSignalWithAccount:(NSString *)account withPassword:(NSString *)password
- (RACSignal*)loginSignalWithAccount:(NSString*)account withPassword:(NSString*)password
{
RACSignal* singnal = [BaseWLService requireWithProperty:[self requireWithDic:[NSDictionary dictionaryWithObjectsAndKeys:account,@"username",password,@"password", nil] ]];
RACSignal* singnal = [BaseWLService requireWithProperty:[self requireWithDic:[NSDictionary dictionaryWithObjectsAndKeys:account, @"username", password, @"password", nil]]];
return singnal;
}
-(BaseEntity*)requireWithDic:(NSDictionary *)dic
- (BaseEntity*)requireWithDic:(NSDictionary*)dic
{
BaseEntity *pro = [[BaseEntity alloc] init];
BaseEntity* pro = [[BaseEntity alloc] init];
pro.requireType = HTTPRequestTypeWithPOST;
pro.responesOBJ = self.class;
pro.reqURL = @"";
+48 -61
View File
@@ -10,98 +10,86 @@
#import <CommonCrypto/CommonDigest.h>
@implementation NSString (HXAddtions)
+(NSString *) jsonStringWithString:(NSString *) string
+ (NSString*)jsonStringWithString:(NSString*)string
{
return [NSString stringWithFormat:@"\"%@\"",
[[string stringByReplacingOccurrencesOfString:@"\n" withString:@"\\n"] stringByReplacingOccurrencesOfString:@"\"" withString:@"\\\""]
];
[[string stringByReplacingOccurrencesOfString:@"\n" withString:@"\\n"] stringByReplacingOccurrencesOfString:@"\"" withString:@"\\\""]];
}
+(NSString *) jsonStringWithArray:(NSArray *)array
+ (NSString*)jsonStringWithArray:(NSArray*)array
{
NSMutableString *reString = [NSMutableString string];
NSMutableString* reString = [NSMutableString string];
[reString appendString:@"["];
NSMutableArray *values = [NSMutableArray array];
NSMutableArray* values = [NSMutableArray array];
for (id valueObj in array) {
NSString *value = [NSString jsonStringWithObject:valueObj];
NSString* value = [NSString jsonStringWithObject:valueObj];
if (value) {
[values addObject:[NSString stringWithFormat:@"%@",value]];
[values addObject:[NSString stringWithFormat:@"%@", value]];
}
}
[reString appendFormat:@"%@",[values componentsJoinedByString:@","]];
[reString appendString:@"]"];
[reString appendFormat:@"%@", [values componentsJoinedByString:@","]];
[reString appendString:@"]"];
return reString;
}
+(NSString *) jsonStringWithDictionary:(NSDictionary *)dictionary
+ (NSString*)jsonStringWithDictionary:(NSDictionary*)dictionary
{
NSArray *keys = [dictionary allKeys];
NSMutableString *reString = [NSMutableString string];
NSArray* keys = [dictionary allKeys];
NSMutableString* reString = [NSMutableString string];
[reString appendString:@"{"];
NSMutableArray *keyValues = [NSMutableArray array];
for (int i=0; i<[keys count]; i++) {
NSString *name = [keys objectAtIndex:i];
NSMutableArray* keyValues = [NSMutableArray array];
for (int i = 0; i < [keys count]; i++) {
NSString* name = [keys objectAtIndex:i];
id valueObj = [dictionary objectForKey:name];
NSString *value = [NSString jsonStringWithObject:valueObj];
if (value)
{
[keyValues addObject:[NSString stringWithFormat:@"\"%@\":%@",name,value]];
NSString* value = [NSString jsonStringWithObject:valueObj];
if (value) {
[keyValues addObject:[NSString stringWithFormat:@"\"%@\":%@", name, value]];
}
}
[reString appendFormat:@"%@",[keyValues componentsJoinedByString:@","]];
[reString appendFormat:@"%@", [keyValues componentsJoinedByString:@","]];
[reString appendString:@"}"];
return reString;
}
+(NSString *) jsonStringWithObject:(id) object
+ (NSString*)jsonStringWithObject:(id)object
{
NSString *value = nil;
if (!object)
{
NSString* value = nil;
if (!object) {
return value;
}
if ([object isKindOfClass:[NSString class]])
{
if ([object isKindOfClass:[NSString class]]) {
value = [NSString jsonStringWithString:object];
}
else if([object isKindOfClass:[NSDictionary class]])
{
else if ([object isKindOfClass:[NSDictionary class]]) {
value = [NSString jsonStringWithDictionary:object];
}
else if([object isKindOfClass:[NSArray class]])
{
else if ([object isKindOfClass:[NSArray class]]) {
value = [NSString jsonStringWithArray:object];
}
else if([object isKindOfClass:[NSNumber class]])
{
else if ([object isKindOfClass:[NSNumber class]]) {
value = [NSString jsonStringWithString:[object stringValue]];
}
return value;
}
+(NSString *) jsonStringWithRTArray:(NSArray *)array
+ (NSString*)jsonStringWithRTArray:(NSArray*)array
{
NSMutableString *reString = [[NSMutableString alloc] init];
NSMutableString* reString = [[NSMutableString alloc] init];
[reString appendString:@"{"];
NSMutableArray *values = [[NSMutableArray alloc] initWithArray:array];
for (int i=0; i<[values count]; i++)
{
NSString *tempString = [values objectAtIndex:i];
NSString *value = [NSString jsonStringWithString:tempString];
if (i%2 == 0)
{
[reString appendFormat:@"%@:",value];
NSMutableArray* values = [[NSMutableArray alloc] initWithArray:array];
for (int i = 0; i < [values count]; i++) {
NSString* tempString = [values objectAtIndex:i];
NSString* value = [NSString jsonStringWithString:tempString];
if (i % 2 == 0) {
[reString appendFormat:@"%@:", value];
}
else
{
if (i == [values count]-1)
{
[reString appendFormat:@"%@",value];
else {
if (i == [values count] - 1) {
[reString appendFormat:@"%@", value];
}
else
{
[reString appendFormat:@"%@,",value];
else {
[reString appendFormat:@"%@,", value];
}
}
}
@@ -109,17 +97,16 @@
return reString;
}
- (NSString *) md5
- (NSString*)md5
{
const char *cStr = [self UTF8String];
const char* cStr = [self UTF8String];
unsigned char result[16];
CC_MD5( cStr, strlen(cStr), result ); // This is the md5 call
CC_MD5(cStr, (int)strlen(cStr), result); // This is the md5 call
return [NSString stringWithFormat:
@"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
result[0], result[1], result[2], result[3],
result[4], result[5], result[6], result[7],
result[8], result[9], result[10], result[11],
result[12], result[13], result[14], result[15]
];
@"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
result[0], result[1], result[2], result[3],
result[4], result[5], result[6], result[7],
result[8], result[9], result[10], result[11],
result[12], result[13], result[14], result[15]];
}
@end
+6 -8
View File
@@ -11,12 +11,10 @@
// Include any system framework and library headers here that should be included in all compilation units.
// You will also need to set the Prefix Header build setting of one or more of your targets to reference this file.
#import <ReactiveCocoa/ReactiveCocoa.h>
#import <Foundation/Foundation.h>
#import <Mantle.h>
#import "Common.h"
#import "BaseEntity.h"
#import "BaseWLService.h"
#import <MBProgressHUD.h>
#import "MBProgressHUD+Util.h"
//#import "Common.h"
//#import "BaseEntity.h"
//#import "BaseWLService.h"
//#import "MBProgressHUD+Util.h"
#import <Mantle/Mantle.h>
#endif /* PrefixHeader_pch */
+2
View File
@@ -7,8 +7,10 @@
//
#import "AWordDefault.h"
#import "Common.h"
#import "LoginViewController.h"
#import "LoginViewModel.h"
#import "MBProgressHUD+Util.h"
@interface LoginViewController ()
@property (weak, nonatomic) IBOutlet UIButton* sureBtn;
+5 -4
View File
@@ -6,15 +6,16 @@
// Copyright © 2015年 ash. All rights reserved.
//
#import "BaseViewModel.h"
#import "BaseEntity.h"
#import "BaseModel.h"
#import "BaseViewModel.h"
@implementation BaseViewModel
+(BaseEntity*)requireWithDic:(NSDictionary *)dic withModel:(BaseModel*)model
+ (BaseEntity*)requireWithDic:(NSDictionary*)dic withModel:(BaseModel*)model
{
BaseEntity *pro = [[BaseEntity alloc] init];
BaseEntity* pro = [[BaseEntity alloc] init];
pro.requireType = HTTPRequestTypeWithGET;
pro.responesOBJ = model.class;
pro.responesOBJ = [(id)model class];
pro.reqURL = @"";
pro.pro = dic;
return pro;