iOS Question Cocoa Error 3840

Discussion in 'iOS Questions' started by Rokiu86, Apr 7, 2015.

  1. Rokiu86

    Rokiu86 Member Licensed User

    Hi.

    I have an issue. Here the code: (very simple)

    Code:
    Sub JobDone (job As HttpJob)

      
    If job.Success = True Then

      
    Dim parser As JSONParser
      parser.Initialize(job.GetString)
      
    Dim rows As List
    line 
    94: rows= parser.NextArray
    ...
    Error:
    Application_Start
    Application_Active
    Error occurred on line: 94 (main)
    Error parsing string: Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (Garbage at end.) UserInfo=0x17e5dac0 {NSDebugDescription=Garbage at end.}
    Stack Trace: (
    CoreFoundation <redacted> + 150
    libobjc.A.dylib objc_exception_throw + 38
    CoreFoundation <redacted> + 0
    ConexionWS -[B4IJSONParser parse] + 212
    ConexionWS -[b4i_main _jobdone:] + 1600
    CoreFoundation <redacted> + 68
    CoreFoundation <redacted> + 300
    ConexionWS +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1928
    ConexionWS -[B4IShell runMethod:] + 496
    ConexionWS -[B4IShell raiseEventImpl:method:args::] + 1846
    ConexionWS -[B4IShellBI raiseEvent:event:params:] + 1316
    ConexionWS -[B4ICommon CallSub4::::] + 346
    ConexionWS -[B4ICommon CallSub2::::] + 254
    ConexionWS -[b4i_httpjob _complete::] + 414
    ConexionWS -[b4i_httputils2service _completejob::::] + 752
    ConexionWS -[b4i_httputils2service _hc_responsesuccess::] + 296
    CoreFoundation <redacted> + 68
    CoreFoundation <redacted> + 300
    ConexionWS +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1928
    ConexionWS -[B4IShell runMethod:] + 496
    ConexionWS -[B4IShell raiseEventImpl:method:args::] + 2060
    ConexionWS -[B4IShellBI raiseEvent:event:params:] + 1316
    ConexionWS __61-[B4IHttp URLSession:downloadTask:didFinishDownloadingToURL:]_block_invoke + 244
    libdispatch.dylib <redacted> + 368
    libdispatch.dylib <redacted> + 22
    libdispatch.dylib <redacted> + 1322
    CoreFoundation <redacted> + 8
    CoreFoundation <redacted> + 1512
    CoreFoundation CFRunLoopRunSpecific + 476
    CoreFoundation CFRunLoopRunInMode + 106
    GraphicsServices GSEventRunModal + 136
    UIKit UIApplicationMain + 1440
    ConexionWS main + 116
    libdyld.dylib <redacted> + 2
    )


    Local Mac Builder libraries:
    h files
    • iAd: 1.00
    • iAdMob: 1.10
    • iArchiver: 1.01
    • iBarcode: 1.03
    • iBLE: 1.11
    • iCore: 1.78
    • iDebug: 1.60
    • iDesigner: 1.20
    • iDropboxSync: 1.00
    • iEncryption: 1.02
    • iGoogleMaps: 1.00
    • iHttp: 1.01
    • iHUD: 1.00
    • iJSON: 1.0
    • iLeadbolt: 1.00
    • iLocation: 1.00
    • iMedia: 1.20
    • iNet: 1.20
    • iNetwork: 1.10
    • iPhone: 1.30
    • iRandomAccessFile: 1.20
    • iSideMenu: 1.00
    • iSQL: 1.01
    • iStore: 1.0
    • iStringUtils: 1.00
    • iWebSocket: 1.00
    • iXmlBuilder: 1.00
    • iXmlSax: 1.00
    a files
    • libCore, size=2206664, modified=01/18/2015 07:26:40
    • libiAd, size=25928, modified=01/19/2015 09:29:26
    • libiAdMob, size=46464, modified=01/19/2015 08:36:16
    • libiArchiver, size=155824, modified=12/15/2014 16:21:18
    • libiBarcode, size=103200, modified=12/11/2014 08:12:00
    • libiBLE, size=83232, modified=01/21/2015 07:32:58
    • libiDebug, size=705024, modified=01/05/2015 16:05:50
    • libiDesigner, size=570768, modified=01/07/2015 15:06:50
    • libiDropboxSync, size=56408, modified=11/17/2014 09:07:32
    • libiEncryption, size=46664, modified=01/06/2015 11:33:32
    • libiGoogleMaps, size=107240, modified=10/30/2014 14:42:54
    • libiHttp, size=84712, modified=01/07/2015 08:56:56
    • libiHUD, size=192376, modified=10/30/2014 14:44:26
    • libiJSON, size=36576, modified=10/30/2014 14:44:56
    • libiLeadbolt, size=7744, modified=12/01/2014 13:35:54
    • libiLocation, size=50384, modified=11/16/2014 07:44:00
    • libiMedia, size=174752, modified=01/11/2015 11:53:52
    • libiNet, size=363344, modified=01/13/2015 15:29:32
    • libiNetwork, size=179168, modified=12/15/2014 10:16:38
    • libiPhone, size=153512, modified=01/12/2015 15:59:34
    • libiRandomAccessFile, size=249928, modified=12/16/2014 16:21:22
    • libiSideMenu, size=338504, modified=10/30/2014 14:50:00
    • libiSQL, size=243848, modified=12/23/2014 14:47:28
    • libiStore, size=35528, modified=01/20/2015 17:01:02
    • libiStringUtils, size=38168, modified=10/30/2014 14:50:50
    • libiWebSocket, size=265616, modified=01/06/2015 08:49:40
    • libiXmlBuilder, size=103920, modified=12/28/2014 15:46:22
    • libiXmlSax, size=42528, modified=10/30/2014 14:51:04

    I read about this issue but not for B4i.

    With my web browser, I can see this Json string with post method:
    [{"nombre":"MODA"},{"nombre":"PERFUMES"}]

    I tested with json tree Example and is ok.

    Thanks for help!!
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Add a Log(job.GetString) to check the returned string. Based on the error message there is some invalid char(s) at the end of the string.
     
  3. Rokiu86

    Rokiu86 Member Licensed User

    Hi.

    Here is the log, adding Log(job.GetString). Return a json string and a HTML code. It's fine???

    Code:
    Application_Start
    Application_Active

    [{
    "nombre":"MODA"},{"nombre":"PERFUMES"}]

    <!DOCTYPE html>

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head><title>

    </title></head>
    <body>
        <form method="post" action="WFClient.aspx?operacion=SP_Categoria_Consultar&amp;idCategoria" id="form1">
    <input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="kD6Zkpn/OY5glrh6GYw+jT6c93XkfgIw6MkCEXWyYjxMHfHiB6v4PJ176elMwx7iY7Pw7+JuSODNDGpp0PenZ+vN0oomdbNT+NDEHwn5x8g=" />

        <div>
       
        </div>
        </form>
    </body>
    </html>
    Error occurred on line: 92 (main)
    Error parsing string: Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (Garbage at end.) UserInfo=0x16e7b110 {NSDebugDescription=Garbage at end.}
    Stack Trace: (
      CoreFoundation       <redacted> + 150
      libobjc.A.dylib      objc_exception_throw + 38
      CoreFoundation       <redacted> + 0
      ConexionWS           -[B4IJSONParser parse] + 212
      ConexionWS           -[B4IJSONParser NextArray] + 66
      ConexionWS           -[b4i_main _jobdone:] + 1396
      CoreFoundation       <redacted> + 68
      CoreFoundation       <redacted> + 300
      ConexionWS           +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1928
      ConexionWS           -[B4IShell runMethod:] + 496
     ConexionWS           -[B4IShell raiseEventImpl:method:args::] + 1846
     ConexionWS           -[B4IShellBI raiseEvent:event:params:] + 1316
     ConexionWS           -[B4ICommon CallSub4::::] + 346
     ConexionWS           -[B4ICommon CallSub2::::] + 254
     ConexionWS           -[b4i_httpjob _complete::] + 414
     ConexionWS           -[b4i_httputils2service _completejob::::] + 752
     ConexionWS           -[b4i_httputils2service _hc_responsesuccess::] + 296
     CoreFoundation       <redacted> + 68
     CoreFoundation       <redacted> + 300
     ConexionWS           +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1928
     ConexionWS           -[B4IShell runMethod:] + 496
     ConexionWS           -[B4IShell raiseEventImpl:method:args::] + 2060
     ConexionWS           -[B4IShellBI raiseEvent:event:params:] + 1316
     ConexionWS           __61-[B4IHttp URLSession:downloadTask:didFinishDownloadingToURL:]_block_invoke + 244
     libdispatch.dylib    <redacted> + 368
     libdispatch.dylib    <redacted> + 22
     libdispatch.dylib    <redacted> + 1322
     CoreFoundation       <redacted> + 8
     CoreFoundation       <redacted> + 1512
     CoreFoundation       CFRunLoopRunSpecific + 476
     CoreFoundation       CFRunLoopRunInMode + 106
     GraphicsServices     GSEventRunModal + 136
     UIKit                UIApplicationMain + 1440
     ConexionWS           main + 116
     libdyld.dylib        <redacted> + 2
    )
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    No. You should first remove the non-json string:
    Code:
    Dim s As String  = Job.GetString
    s = s.SubString(
    0, s.IndexOf("]") + 1)
    'now you can parse s as a json string
     
  5. Rokiu86

    Rokiu86 Member Licensed User

    It's working! Thanks!
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice