Close Menu
  • Home
  • AI
  • Big Data
  • Cloud Computing
  • iOS Development
  • IoT
  • IT/ Cybersecurity
  • Tech
    • Nanotechnology
    • Green Technology
    • Apple
    • Software Development
    • Software Engineering

Subscribe to Updates

Get the latest technology news from Bigteetechhub about IT, Cybersecurity and Big Data.

    What's Hot

    What is quantum computing? 10 terms everyone should know

    April 13, 2026

    Firebase App Check debug token returns 403 “App attestation failed” on iOS Flutter app — misleading error hides API key restriction

    April 13, 2026

    A simpler path to unified, AI-ready network operations

    April 12, 2026
    Facebook X (Twitter) Instagram
    Facebook X (Twitter) Instagram
    Big Tee Tech Hub
    • Home
    • AI
    • Big Data
    • Cloud Computing
    • iOS Development
    • IoT
    • IT/ Cybersecurity
    • Tech
      • Nanotechnology
      • Green Technology
      • Apple
      • Software Development
      • Software Engineering
    Big Tee Tech Hub
    Home»iOS Development»ios – Swift string truncates / does not hold enough content
    iOS Development

    ios – Swift string truncates / does not hold enough content

    big tee tech hubBy big tee tech hubMarch 4, 2026013 Mins Read
    Share Facebook Twitter Pinterest Copy Link LinkedIn Tumblr Email Telegram WhatsApp
    Follow Us
    Google News Flipboard
    ios – Swift string truncates / does not hold enough content
    Share
    Facebook Twitter LinkedIn Pinterest Email Copy Link


    I am trying to build up something that uses wkwebview and javascript..So, I am having terrible issues with strings..

    They are way too short, meaning that they don’t have enough capacity. I have understood that string’s capacity is huge, something like that it could fit a bible inside it.. Yet; I am experiencing trouble with it. First, json replies from post message, got truncated, so I had to begin creating methods that shrink json to parts.. Not ideal, not at all.. Anyway..

    My script is here:

    var script: String = ""
            
            script += """
    
                let json = JSON.parse(data);
                if (json && json['cargo'] && json['cargo']['loads'] && Array.isArray(json['cargo']['loads']) && Object.keys(json['cargo']['loads']).length > 0 && json['cargo']['loads'][0]['id']) {
                    var obj = new Object();
                    obj.id = json['cargo']['loads'][0]['id'];
                    obj.ordererReference = json['cargo']['loads'][0]['ordererReference'];
                    obj.fromname = json['cargo']['loads'][0]['consignorName];
                    obj.fromstreet = json['cargo']['loads'][0]['consignorStreetAddr'];
                    obj.frompost = json['cargo']['loads'][0]['consignorPostCode'] + " " + json['cargo']['loads'][0]['consignorPostOffice'];
                    obj.fromphone = json['cargo']['loads'][0]['consignorPhone'];
                    obj.fromcoords = json['cargo']['loads'][0]['consignorCoordinateX'] + "," + json['cargo']['loads'][0]['consignorCoordinateY'];
                    obj.toname = json['cargo']['loads'][0]['consigneeName'];
                    obj.tostreet = json['cargo']['loads'][0]['consigneeStreetAddr'];
                    obj.topost = json['cargo']['loads'][0]['consigneePostCode'] + " " + json['cargo']['loads'][0]['consigneePostOffice'];
                    obj.tophone = json['cargo']['loads'][0]['consigneePhone'];
                    obj.tocoords = json['cargo']['loads'][0]['consigneeCoordinateX'] + " " + json['cargo']['loads'][0]['consigneeCoordinateY'];
                    obj.toemail = json['cargo']['loads'][0]['consigneeEmail'];
                    obj.organizer = json['cargo']['loads'][0]['responsiblePerson'];
                    obj.organizerPhone = json['cargo']['loads'][0]['responsiblePhone'];
                    obj.loadArrive = json['cargo']['loads'][0]['loadingPlaceArrival'];
                    obj.loadBegun = json['cargo']['loads'][0]['fetchTimeRealisationStart'];
                    obj.loadEnd = json['cargo']['loads'][0]['fetchTimeRealisation'];
                    obj.deliveryArrive = json['cargo']['loads'][0]['deliveryPlaceArrival'];
                    obj.deliveryBegun = json['cargo']['loads'][0]['deliveryTimeRealisationStart'];
                    obj.deliveryEnd = json['cargo']['loads'][0]['deliveryTimeRealisation'];
                    obj.waybill = json['cargo']['loads'][0]['waybillPdfUrl'];
                    obj.comments = json['cargo']['loads'][0]['comments'];
                    window.webkit.messageHandlers.openLoadDetails.postMessage(JSON.stringify(obj));
                } else {
                    window.webkit.messageHandlers.requestError.postMessage("failed to get load details")
                }
            """
    

    and this is what script string variable contains:

    let json = JSON.parse(data);
        if (json && json['cargo'] && json['cargo']['loads'] && Array.isArray(json['cargo']['loads']) && Object.keys(json['cargo']['loads']).length > 0 && json['cargo']['loads'][0]['id']) {
            var obj = new Object();
            obj.id = json['cargo']['loads'][0]['id'];
            obj.ordererReference = json['cargo']['loads'][0]['ordererReference'];
            obj.fromname = json['cargo']['loads'][0]['consignorName];
            obj.fromstreet = json['cargo']['loads'][0]['consignorStreetAddr'];
            obj.frompost = json['cargo']['loads'][0]['consignorPostCode'] + " " + json['cargo']['loads'][0]['consignorPostOffice'];
            obj.fromphone = json['cargo']['loads'][0]['consignorPhone'];
            obj.fromcoords = json['cargo']['loads'][0]['consignorCoordinateX'] + "," + json['cargo']['loads'][0]['consignorCoordinateY'];
            obj.toname = json['cargo']['loads'][0]['consigneeName'];
            obj.tostreet = json['cargo']['loads'][0]['consigneeStreetAddr'];
            obj.topost = json
    

    Yes, that’s where it truncates. I first thought that there is a “invisible” character that causes this.. Nothing like that. Then I tried to append to string after this, and it still is the same, second string that I append to it.. Just “disappears”..

    Okay, maybe there’s something I can’t see.. So I remove all content.. Open up a wikipedia with swift page on it, copy a rather big portion from there and insert that to script variable – just to see that it happens again, article gets truncated as well..

    What is going on??? How can I make “a long string”? Is there a project setting somewhere that has gone wrong and then limits string’s maximum length? So frustrating..

    I tried to search for this, but it seems that this isn’t very common problem – or I am looking with wrong keywords..



    Source link

    Content hold iOS String Swift truncates
    Follow on Google News Follow on Flipboard
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email Copy Link
    tonirufai
    big tee tech hub
    • Website

    Related Posts

    Firebase App Check debug token returns 403 “App attestation failed” on iOS Flutter app — misleading error hides API key restriction

    April 13, 2026

    javascript – React Native iOS app crashes on language change with react-native-restart (works on Android)

    April 12, 2026

    ios – React web app hitting memory limit on mobile

    April 11, 2026
    Add A Comment
    Leave A Reply Cancel Reply

    Editors Picks

    What is quantum computing? 10 terms everyone should know

    April 13, 2026

    Firebase App Check debug token returns 403 “App attestation failed” on iOS Flutter app — misleading error hides API key restriction

    April 13, 2026

    A simpler path to unified, AI-ready network operations

    April 12, 2026

    Launching S3 Files, making S3 buckets accessible as file systems

    April 12, 2026
    About Us
    About Us

    Welcome To big tee tech hub. Big tee tech hub is a Professional seo tools Platform. Here we will provide you only interesting content, which you will like very much. We’re dedicated to providing you the best of seo tools, with a focus on dependability and tools. We’re working to turn our passion for seo tools into a booming online website. We hope you enjoy our seo tools as much as we enjoy offering them to you.

    Don't Miss!

    What is quantum computing? 10 terms everyone should know

    April 13, 2026

    Firebase App Check debug token returns 403 “App attestation failed” on iOS Flutter app — misleading error hides API key restriction

    April 13, 2026

    Subscribe to Updates

    Get the latest technology news from Bigteetechhub about IT, Cybersecurity and Big Data.

      • About Us
      • Contact Us
      • Disclaimer
      • Privacy Policy
      • Terms and Conditions
      © 2026 bigteetechhub.All Right Reserved

      Type above and press Enter to search. Press Esc to cancel.