Skip to content

Commit be4d2a4

Browse files
committed
immutable -> mutable
immutable -> mutable
1 parent 60c58f3 commit be4d2a4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1258
-527
lines changed

MJExtension.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "MJExtension"
3-
s.version = "3.0.3"
3+
s.version = "3.0.4"
44
s.ios.deployment_target = '6.0'
55
s.osx.deployment_target = '10.8'
66
s.summary = "A fast and convenient conversion between JSON and model"

MJExtension/NSObject+MJKeyValue.m

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,18 @@ - (instancetype)mj_setKeyValues:(id)keyValues context:(NSManagedObjectContext *)
115115
MJPropertyType *type = property.type;
116116
Class propertyClass = type.typeClass;
117117
Class objectClass = [property objectClassInArrayForClass:[self class]];
118+
119+
// 不可变 -> 可变处理
120+
if (propertyClass == [NSMutableArray class] && [value isKindOfClass:[NSArray class]]) {
121+
value = [NSMutableArray arrayWithArray:value];
122+
} else if (propertyClass == [NSMutableDictionary class] && [value isKindOfClass:[NSDictionary class]]) {
123+
value = [NSMutableDictionary dictionaryWithDictionary:value];
124+
} else if (propertyClass == [NSMutableString class] && [value isKindOfClass:[NSString class]]) {
125+
value = [NSMutableString stringWithString:value];
126+
} else if (propertyClass == [NSMutableData class] && [value isKindOfClass:[NSData class]]) {
127+
value = [NSMutableData dataWithData:value];
128+
}
129+
118130
if (!type.isFromFoundation && propertyClass) { // 模型属性
119131
value = [propertyClass mj_objectWithKeyValues:value context:context];
120132
} else if (objectClass) {

MJExtension/NSString+MJExtension.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ - (BOOL)mj_isPureInt
7171

7272
- (NSURL *)mj_url
7373
{
74+
// [self stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet characterSetWithCharactersInString:@"!$&'()*+,-./:;=?@_~%#[]"]];
75+
7476
return [NSURL URLWithString:(NSString *)CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)self, (CFStringRef)@"!$&'()*+,-./:;=?@_~%#[]", NULL,kCFStringEncodingUTF8))];
7577
}
7678
@end

MJExtensionExample.xcodeproj/project.pbxproj

Lines changed: 504 additions & 223 deletions
Large diffs are not rendered by default.

MJExtensionExample/AppDelegate.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//
2+
// AppDelegate.h
3+
// MJExtensionExample
4+
//
5+
// Created by MJ Lee on 15/11/8.
6+
// Copyright © 2015年 小码哥. All rights reserved.
7+
//
8+
9+
#import <UIKit/UIKit.h>
10+
11+
@interface AppDelegate : UIResponder <UIApplicationDelegate>
12+
13+
@property (strong, nonatomic) UIWindow *window;
14+
15+
16+
@end
17+

MJExtensionExample/AppDelegate.m

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
//
2+
// AppDelegate.m
3+
// MJExtensionExample
4+
//
5+
// Created by MJ Lee on 15/11/8.
6+
// Copyright © 2015年 小码哥. All rights reserved.
7+
//
8+
9+
#import "AppDelegate.h"
10+
11+
@interface AppDelegate ()
12+
13+
@end
14+
15+
@implementation AppDelegate
16+
17+
18+
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
19+
// Override point for customization after application launch.
20+
return YES;
21+
}
22+
23+
- (void)applicationWillResignActive:(UIApplication *)application {
24+
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
25+
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
26+
}
27+
28+
- (void)applicationDidEnterBackground:(UIApplication *)application {
29+
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
30+
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
31+
}
32+
33+
- (void)applicationWillEnterForeground:(UIApplication *)application {
34+
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
35+
}
36+
37+
- (void)applicationDidBecomeActive:(UIApplication *)application {
38+
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
39+
}
40+
41+
- (void)applicationWillTerminate:(UIApplication *)application {
42+
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
43+
}
44+
45+
@end
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "iphone",
5+
"size" : "29x29",
6+
"scale" : "2x"
7+
},
8+
{
9+
"idiom" : "iphone",
10+
"size" : "29x29",
11+
"scale" : "3x"
12+
},
13+
{
14+
"idiom" : "iphone",
15+
"size" : "40x40",
16+
"scale" : "2x"
17+
},
18+
{
19+
"idiom" : "iphone",
20+
"size" : "40x40",
21+
"scale" : "3x"
22+
},
23+
{
24+
"size" : "60x60",
25+
"idiom" : "iphone",
26+
"filename" : "MJExtension.png",
27+
"scale" : "2x"
28+
},
29+
{
30+
"size" : "60x60",
31+
"idiom" : "iphone",
32+
"filename" : "MJExtension-1.png",
33+
"scale" : "3x"
34+
}
35+
],
36+
"info" : {
37+
"version" : 1,
38+
"author" : "xcode"
39+
}
40+
}
14 KB
Loading
14 KB
Loading
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"version" : 1,
4+
"author" : "xcode"
5+
}
6+
}

0 commit comments

Comments
 (0)