Swift for Xojo Developers : Introduction

A few years ago when Xojo released “Xojo for iOS”, I was excited… until I say everything that was missing or constrained with the product. It was then that I decided to teach myself Swift. And one thing that I did, both to teach myself things, but also to give me tools to use in the future, I began writing a number of “frameworks” [not just a term, not a true Swift Framework (yet) ]

What I plan on doing here, unless there is no interest, is to post a series of these code modules, almost all of which wrap Swift code into methods or functions that mimic as closely as possible a Xojo method or function.

The first one will involve File Management
here are the signatures for the classes that will be in the first few postings

class folderitem {
    var name : String {
    var parent           : folderitem 
    var displayName      : String    
    var exists           : Bool     
    var isFolder         : Bool     
    var isWriteable      : Bool    
    var isReadable       : Bool    
    var lastErrorCode    : Int    
    var lastErrorMessage : String   
    var count        : Int  

    var length : Int    
    var modificationDate : String 
    var creationDate     : String 
    var path             : String 
    var URLpath          : String
    var URL              : URL    

    func child(_ name:String) -> folderitem 
    func item(_ index:Int) -> folderitem? 
    func CopyTo(name:String) 
    func MoveTo(destination:String) 
    func CreateAsFolder() 
    func Delete() 

class SpecialFolderClass {
    var Documents : folderitem 
    var ApplicationSupport : folderitem 
    var Resources : folderitem 
    var Temporary : folderitem 

class textOutputFile {
    func Append(_ f : folderitem ) 
    func Create(_ f : folderitem ) 
    var lastErrorCode     : Int    
    var writeError        : Bool    
    var lastErrorMessage  : String  
    func close() 
    func writeLine(_ data : String) 
    func write(_ data : String) 

class textInputFile {
    var lastErrorCode     : Int     
    var readError         : Bool   
    var lastErrorMessage  : String 

    func open(_ f : folderitem ) 
    var EOF : Bool 
    func close() 
    var readALL : String 
    var readLine : String? 

The first one will be FOLDERITEM… once I finish adding all the required comments.
Note this comments will attempt to follow the Xcode Markdown syntax

Also, if anyone sees ANYTHING that could be made better, PLEASE let me know.
Some of these were written back in Swift2.0 and things have changed between now and then.


If anyone has any questions about any of these classes, or would like the Xcode source to anything I have posted, just send me a PM.

Have to confess that I am so busy right at the moment that I’ve only skimmed most of the posts

Need longer days - anyone in for a 40 hour day ? maybe metric days of 100 hours, weeks of 10 days, and months with 10 weeks ?

1 Like

I dread to think what the lack of sleep I subject myself is doing to me in the long run. It’s the only way to cram everything into the day though.

1 Like

I will be interested after Xmas caught up with deadlines etc