Skip to content

Commit

Permalink
v6.5 ios端udp版SDK工程提交
Browse files Browse the repository at this point in the history
  • Loading branch information
JackJiang2011 committed May 7, 2024
1 parent 661fc70 commit b2a674c
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -574,7 +574,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES;
Expand All @@ -584,7 +584,7 @@
EADDE5EE1A0A122E002FFB8E /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
OTHER_LDFLAGS = (
"-ObjC",
"-all_load",
Expand All @@ -598,7 +598,7 @@
isa = XCBuildConfiguration;
buildSettings = {
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
OTHER_LDFLAGS = (
"-ObjC",
"-all_load",
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ - (void) reachabilityChanged:(NSNotification *)note
case ReachableViaWiFi: // WIFI
{
int wifi = (netStatus == ReachableViaWiFi);
statusString= [NSString stringWithFormat:NSLocalizedString(@"【IMCORE-UDP】【本地网络通知】检测本地网络已连接上了! WIFI? %d", @""), wifi?@"YES":@"NO"];
statusString= [NSString stringWithFormat:NSLocalizedString(@"【IMCORE-UDP】【本地网络通知】检测本地网络已连接上了! WIFI? %@", @""), wifi?@"YES":@"NO"];

// self.localDeviceNetworkOk = true;
[[LocalSocketProvider sharedInstance] closeLocalSocket];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// RMMapper
//
// Created by Roomorama on 28/6/13.
// Revision by Jack Jiang on 30/4/24.
// Copyright (c) 2013 Roomorama. All rights reserved.
//

Expand All @@ -21,6 +22,6 @@

/** Load to NSUserDefaults
*/
-(id) rm_customObjectForKey:(NSString*)key;
-(id) rm_customObjectForKey:(NSString*)key withClass:(Class)clazz;

@end
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,50 @@ -(void)rm_setCustomObject:(id)obj forKey:(NSString *)key {
NSLog(@"Error save object to NSUserDefaults. Object must respond to encodeWithCoder: message");
return;
}
NSData *encodedObject = [NSKeyedArchiver archivedDataWithRootObject:obj];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:encodedObject forKey:key];
[defaults synchronize];

// NSData *encodedObject = [NSKeyedArchiver archivedDataWithRootObject:obj];
// NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
// [defaults setObject:encodedObject forKey:key];
// [defaults synchronize];

NSError *error = nil;
// 或者YES,如果你的对象支持并需要安全编码
BOOL requiresSecureCoding = NO;
// 使用iOS 12以后的新方法进行归档
NSData *archivedData = [NSKeyedArchiver archivedDataWithRootObject:obj
requiringSecureCoding:requiresSecureCoding
error:&error];
if (error) {
NSLog(@"Error during archiving: %@", error.localizedDescription);
} else {
// 成功归档后的处理
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:archivedData forKey:key];
[defaults synchronize];
}
}

-(id)rm_customObjectForKey:(NSString *)key {
-(id)rm_customObjectForKey:(NSString *)key withClass:(Class)clazz {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSData *encodedObject = [defaults objectForKey:key];
id obj = [NSKeyedUnarchiver unarchiveObjectWithData:encodedObject];
return obj;

// id obj = [NSKeyedUnarchiver unarchiveObjectWithData:encodedObject];
// return obj;

NSError *error = nil;
// 使用iOS 12以后的新方法进行反归档
id myObject = [NSKeyedUnarchiver unarchivedObjectOfClass:clazz fromData:encodedObject error:&error];

if (error) {
NSLog(@"Error during unarchiving: %@", error.localizedDescription);
} else if (myObject) {
// 成功解档后的处理
return myObject;
} else {
NSLog(@"Unable to unarchive object.");
}

return nil;
}

@end
@end

0 comments on commit b2a674c

Please sign in to comment.