我将Xcode更新为7.0或iOS 9.0时遇到问题.不知怎的,它开始给我标题错误
"无法加载资源,因为App Transport Security策略要求使用安全连接"
Web服务方法:
-(void)ServiceCall:(NSString*)ServiceName :(NSString *)DataString
{
NSURLSessionConfiguration *sessionConfiguration = [NSURLSessionConfiguration defaultSessionConfiguration];
[sessionConfiguration setAllowsCellularAccess:YES];
[sessionConfiguration setHTTPAdditionalHeaders:@{ @"Accept" : @"application/json" }];
NSURLSession *session = [NSURLSession sessionWithConfiguration:sessionConfiguration];
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@",ServiceURL]];
NSLog(@"URl %@%@",url,DataString);
// Configure the Request
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setValue:[NSString stringWithFormat:@"%@=%@", strSessName, strSessVal] forHTTPHeaderField:@"Cookie"];
request.HTTPBody = [DataString dataUsingEncoding:NSUTF8StringEncoding];
request.HTTPMethod = @"Post";
// post the request and handle response
NSURLSessionDataTask *postDataTask = [session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error)
{
// Handle the …
Run Code Online (Sandbox Code Playgroud) 我需要获取唯一的设备ID来填充数据库中的唯一用户ID.我使用以下代码来实现.
NSString *strApplicationUUID= [[[UIDevice currentDevice] identifierForVendor] UUIDString];
但是当我重新安装应用程序时,UUID一直在变化.但据我所知,设备ID永远不会改变.为此,我使用下面的代码与第三方SSKeychain
保存并检索旧的UDID:
NSString *Appname = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"];
NSString *strApplicationUUID = [SSKeychain passwordForService:Appname account:@"manab"];
if (strApplicationUUID == nil)
{
strApplicationUUID = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
[SSKeychain setPassword:strApplicationUUID forService:Appname account:@"manab"];
}
Run Code Online (Sandbox Code Playgroud)
现在问题是当该应用程序的版本被更改时,即app v2.0表单app v1.0然后UDID再次更改.所以逻辑很清楚我没有得到唯一的UDID,我只是将UDID作为供应商或应用程序的基础.
如何以编程方式获得它?有没有其他办法,请告诉我正确的方向.