应用程序在 iphone4 上加载,但不在 3g 上加载..nil 字符串参数

发布于 2024-09-16 13:45:46 字数 5012 浏览 5 评论 0原文

请帮助..我无法解决这个奇怪的问题。我的应用程序有 iAds 和多任务支持。该应用程序可以部署到 iphone 上并且运行得很好,但是当我尝试在 iphone 3g(使用 iOS 3.1.2)上部署我的应用程序时,它在控制台上抛出以下错误。我尝试注释掉 iAds 的代码,但不确定这里发生了什么。请帮助大家。谢谢

[Session started at 2010-08-31 13:01:05 -0500.]
GNU gdb 6.3.50-20050815 (Apple version gdb-1470) (Thu May 27 05:54:06 UTC 2010)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "--host=i386-apple-darwin --target=arm-apple-darwin".tty /dev/ttys003
Loading program into debugger…
warning: Unable to read symbols from "iAd" (not yet mapped into memory).
Program loaded.
target remote-mobile /tmp/.XcodeGDBRemote-32678-64
Switching to remote-macosx protocol
mem 0x1000 0x3fffffff cache
mem 0x40000000 0xffffffff none
mem 0x00000000 0x0fff none
run
Running…
[Switching to thread 11779]
[Switching to thread 11779]
sharedlibrary apply-load-rules all
continue
2010-08-31 13:02:14.666 SugarCRMReleaseOne[5256:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSURL initWithString:relativeToURL:]: nil string parameter'
2010-08-31 13:02:14.709 SugarCRMReleaseOne[5256:207] Stack: (
    853417245,
    845594132,
    852966195,
    852966099,
    871903965,
    871903579,
    871903537,
    211149,
    211529,
    147487,
    171893,
    290105,
    279933,
    853174415,
    818198404,
    818198252,
    818198196,
    818197260,
    818200460,
    818194688,
    818192276,
    818173840,
    818172052,
    834382224,
    853165355,
    853163039,
    834376564,
    817839152,
    817832496,
    8857,
    8720
)
terminate called after throwing an instance of 'NSException'
Program received signal:  “SIGABRT”.
kill
quit

编辑

1 [syncDelegateImpl loginHandler];

2 -(void) 登录处理程序 { SCRMsugarsoap* 服务 = [[SCRMsugarsoap alloc] initWithUrl:serverURL]; 服务.日志记录=是; service.username = 用户名; 服务.密码 = 密码; [服务登录:自我操作:@selector(sessionIdHandler:) user_auth:[[[SCRMuser_auth alloc] initWithUsername:用户名和密码:密码]autorelease] application_name:@“”]; [服务发布]; }

3 当遇到 [服务登录:自我操作:@selector(sessionIdHandler:) user_auth:[[[SCRMuser_auth alloc] initWithUsername:用户名和密码:密码]autorelease] application_name:@“”];

  • (id) initWithUsername: (NSString*) 用户名​​和密码: (NSString*) pass { if(self = [超级初始化]) { Soap *converter = [[Soap alloc] init]; SCRMsugarsoap *service = [[SCRMsugarsoap alloc] init];

     [service get_server_version:self action:@selector(get_server_versionHandler:)];
    
        self.user_name = 用户名;
        self.password = [转换器 tomd5:pass];
    
        [转换器发布];
        [服务发布];
    }
    返回自我;
    

    }

现在当遇到 [service get_server_version:self action:@selector(get_server_versionHandler:)];在上述方法中..

  • (SoapRequest*) get_server_version: (id) _target action: (SEL) _action { NSMutableArray* _params = [NSMutableArray 数组];

    NSString* _envelope = [Soap createEnvelope: @"get_server_version" forNamespace: self.namespace withParameters: _params withHeaders: self.headers];
    SoapRequest* _request = [SoapRequest 创建:_target 操作:_action 服务:selfsoapAction:(@"%@/get_server_version",serverURL) postData:_envelope deserializeTo:@"NSString"];
    [_请求发送];
    返回_请求;
    

    }

    5 现在它尝试调用 SOAP Request 类方法

    • (SoapRequest*)创建:(SoapHandler*)处理程序操作:(SEL)操作服务:(SoapService*)服务soapAction:(NSString*)soapAction postData:(NSString*)postData deserializeTo:(id)deserializeTo { SoapRequest* 请求 = [SoapRequest 创建:处理程序操作:操作 urlString:service.serviceUrlsoapAction:soapAction postData:postData deserializeTo:deserializeTo]; request.defaultHandler = service.defaultHandler; 请求.logging = 服务.logging; 请求.用户名 = 服务.用户名; 请求.密码 = 服务.密码; 退货请求; }

当它尝试设置请求

+ (SoapRequest*) create: (SoapHandler*) handler action: (SEL) action urlString: (NSString*) urlString soapAction: (NSString*) soapAction postData: (NSString*) postData deserializeTo: (id) deserializeTo {
    SoapRequest* request = [[SoapRequest alloc] init];
    //request.url = nil;
    //if(urlString!=nil)
    //{
    request.url=[NSURL URLWithString: urlString];
    //}
    request.soapAction = soapAction;
    request.postData = [postData retain];
    request.handler = handler;
    request.deserializeTo = deserializeTo;
    request.action = action;
    request.defaultHandler = nil;
    return [request autorelease];
}

时,在设置 url 时会调用以下方法,它会抛出 objc_exception_throw 。它在 iphone 4 上工作正常,但当我尝试在 iphone 3 上部署时,它会抛出错误。

我有多任务处理并且我的应用程序中的 iAd 框架和我通过以下方式检查了版本:

if ([[UIDevice currentDevice].systemVersion floatValue] >=3.2)
{
do iphone 4 stuff
}
else
{
do iphone 3 stuff
}

Please help..I am unable to figure out this wierd problem. My app has iAds and multitasking support. The app can be deployed onto the iphone and its running pretty fine but when I tried to deploy my app on iphone 3g(with iOS 3.1.2) it throws the following error on the console. I tried commenting out the code for iAds but not sure whats going on here..Please help guys..thanks

[Session started at 2010-08-31 13:01:05 -0500.]
GNU gdb 6.3.50-20050815 (Apple version gdb-1470) (Thu May 27 05:54:06 UTC 2010)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "--host=i386-apple-darwin --target=arm-apple-darwin".tty /dev/ttys003
Loading program into debugger…
warning: Unable to read symbols from "iAd" (not yet mapped into memory).
Program loaded.
target remote-mobile /tmp/.XcodeGDBRemote-32678-64
Switching to remote-macosx protocol
mem 0x1000 0x3fffffff cache
mem 0x40000000 0xffffffff none
mem 0x00000000 0x0fff none
run
Running…
[Switching to thread 11779]
[Switching to thread 11779]
sharedlibrary apply-load-rules all
continue
2010-08-31 13:02:14.666 SugarCRMReleaseOne[5256:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSURL initWithString:relativeToURL:]: nil string parameter'
2010-08-31 13:02:14.709 SugarCRMReleaseOne[5256:207] Stack: (
    853417245,
    845594132,
    852966195,
    852966099,
    871903965,
    871903579,
    871903537,
    211149,
    211529,
    147487,
    171893,
    290105,
    279933,
    853174415,
    818198404,
    818198252,
    818198196,
    818197260,
    818200460,
    818194688,
    818192276,
    818173840,
    818172052,
    834382224,
    853165355,
    853163039,
    834376564,
    817839152,
    817832496,
    8857,
    8720
)
terminate called after throwing an instance of 'NSException'
Program received signal:  “SIGABRT”.
kill
quit

EDIT

1 [syncDelegateImpl loginHandler];

2 -(void) loginHandler
{
SCRMsugarsoap* service = [[SCRMsugarsoap alloc] initWithUrl:serverURL];
service.logging = YES;
service.username = userName;
service.password = password;
[service login:self action:@selector(sessionIdHandler:) user_auth: [[[SCRMuser_auth alloc] initWithUsername:userName andPassword:password]autorelease] application_name: @""];
[service release];
}

3 When it encounters
[service login:self action:@selector(sessionIdHandler:) user_auth: [[[SCRMuser_auth alloc] initWithUsername:userName andPassword:password]autorelease] application_name: @""];

  • (id) initWithUsername: (NSString*) username andPassword: (NSString*) pass
    {
    if(self = [super init])
    {
    Soap *converter = [[Soap alloc] init];
    SCRMsugarsoap *service = [[SCRMsugarsoap alloc] init];

        [service get_server_version:self action:@selector(get_server_versionHandler:)];
    
        self.user_name = username;
        self.password = [converter tomd5:pass];
    
        [converter release];
        [service release];
    }
    return self;
    

    }

4 Now when it encounter [service get_server_version:self action:@selector(get_server_versionHandler:)]; in the above method..

  • (SoapRequest*) get_server_version: (id) _target action: (SEL) _action
    {
    NSMutableArray* _params = [NSMutableArray array];

    NSString* _envelope = [Soap createEnvelope: @"get_server_version" forNamespace: self.namespace withParameters: _params withHeaders: self.headers];
    SoapRequest* _request = [SoapRequest create: _target action: _action service: self soapAction: (@"%@/get_server_version", serverURL) postData: _envelope deserializeTo: @"NSString"];
    [_request send];
    return _request;
    

    }

    5 Now it tries to call SOAP Request class method

    • (SoapRequest*) create: (SoapHandler*) handler action: (SEL) action service: (SoapService*) service soapAction: (NSString*) soapAction postData: (NSString*) postData deserializeTo: (id) deserializeTo {
      SoapRequest* request = [SoapRequest create: handler action: action urlString: service.serviceUrl soapAction: soapAction postData:postData deserializeTo:deserializeTo];
      request.defaultHandler = service.defaultHandler;
      request.logging = service.logging;
      request.username = service.username;
      request.password = service.password;
      return request;
      }

6 So when it tries to set the request the below method is called

+ (SoapRequest*) create: (SoapHandler*) handler action: (SEL) action urlString: (NSString*) urlString soapAction: (NSString*) soapAction postData: (NSString*) postData deserializeTo: (id) deserializeTo {
    SoapRequest* request = [[SoapRequest alloc] init];
    //request.url = nil;
    //if(urlString!=nil)
    //{
    request.url=[NSURL URLWithString: urlString];
    //}
    request.soapAction = soapAction;
    request.postData = [postData retain];
    request.handler = handler;
    request.deserializeTo = deserializeTo;
    request.action = action;
    request.defaultHandler = nil;
    return [request autorelease];
}

while setting the url it throws objc_exception_throw..It works fine on iphone 4 but when I am trying to deploy on iphone 3 it throws the errors..

I have multitasking and iAd frameworks in my app and I checked for the versions in the following way:

if ([[UIDevice currentDevice].systemVersion floatValue] >=3.2)
{
do iphone 4 stuff
}
else
{
do iphone 3 stuff
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦一生花开无言 2024-09-23 13:45:46

您的问题就在报告中:您将 nil 传递给 initWithString: ,这会导致异常。要么在调用初始化程序之前检查 nil,要么以另一种方式确保字符串值来解决问题。

编辑:我建议简化您的类初始值设定项,但这不是您的问题。如果 urlString 格式不正确,则 URL 将返回 nil。根据 Apple 的文档:用于初始化 NSURL 对象的字符串。必须符合 RFC 2396。此方法根据 RFC 1738 和 1808 解析 URLString。

这可能是您的问题,但我不知道您是否发布了足够的代码来确定。

Your issue is right there in the report: you're passing nil to initWithString: which causes the exception. Either check for nil before calling the initializer or ensure the string value another way to fix the problem.

Edit: I'd recommend simplifying your class initializer, but that's not your problem. If urlString isn't properly formed, the URL will return nil. According to Apple's docs: The string with which to initialize the NSURL object. Must conform to RFC 2396. This method parses URLString according to RFCs 1738 and 1808.

That may be your problem, though I don't know if you posted enough code to be sure.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文