Swift playgrounds (iPad) - define class on one page and use it on another

Discussion in 'iOS Programming' started by Loge, Jan 27, 2018.

  1. Loge macrumors 68020

    Loge

    Joined:
    Jun 24, 2004
    Location:
    England
    #1
    While it's great to be able to have multiple pages in an iOS Swift playground, the scope seems to be entirely limited to the current page.

    So there's no way to define a class on one page and use it on a subsequent page? Unless I'm missing something very obvious.
     
  2. mildocjr macrumors 65816

    #2
    This is probably because playgrounds is primarily a tool to teach newcomers how to code. It still can serve a purpose of allowing you to write sections of your code, but I don't think it was ever meant to be an exact equivalent to Xcode Playgrounds. Just write out your classes from top to bottom, then when you get back to your Mac, copy each class into it's own file. Beyond this, while the Playgrounds app is cool in it's own rights, it might cause performance issues or even run out of memory if you try to stack a bunch of classes/structs in the same Playground. I haven't done much with the Playgrounds app on iPad, but I do know that Xcode Playgrounds on macOS offers enough flexibility to hang itself on typically much more powerful devices. Probably not a wise decision try and do too much with Playgrounds on iPad.
     

Share This Page