niutech

Administrator

Last active [hidden]

  1. 2 years ago
    Thu Mar 24 01:33:45 2016

    Swift 2.2 requires Xcode 7.3, which works in OS X 10.11+. I would recommend at least 4GB RAM.

  2. Thu Mar 24 01:26:47 2016
    niutech posted in Mount Network Share.

    You can do it like this in Swift, using NetFS:

    func mountShare(serverAddress: String, shareName: String, userName: String, password: String) {
        let fm = NSFileManager.defaultManager()
        let mountPoint = "/Volumes/".stringByAppendingString(shareName)
        var isDir : ObjCBool = false
        if fm.fileExistsAtPath(mountPoint, isDirectory: &isDir) {
            if isDir {
                unmount(mountPoint, 0)
                println("Unmounted: \(mountPoint)")
            }
        }
        let sharePath = NSURL(string: "\(serverAddress)/\(shareName)")!
        let mounted : Int32 = NetFSMountURLSync(sharePath, nil, userName, self.decodeStr(password), nil, nil, nil)
        if mounted > 0 {
            println("Error: sharePath: \(sharePath) Not Valid")
        } else {
            println("Mounted: \(sharePath)")
        }
    }

  3. Fri Jan 22 05:27:40 2016
    niutech posted in List FTP Directory.

    Have a look at Rebekka .

    You can use it like this:

    var configuration = SessionConfiguration()
    configuration.host = "ftp://ftp.mozilla.org:21"
    configuration.username = "user"
    configuration.password = "pass"
    configuration.encoding = NSUTF8StringEncoding
    _session = Session(configuration: configuration)
    _session.list("/") {
        (resources, error) -> Void in
        println("List directory with result:\n\(resources), error: \(error)\n\n")
    }

  4. Fri Jan 22 05:01:54 2016

    Here is a tutorial on using Google Maps SDK in Swift .

    Sanple Swift code:

    import UIKit
    import GoogleMaps
    
    class ViewController: UIViewController {
      override func viewDidLoad() {
        super.viewDidLoad()
        let camera = GMSCameraPosition.cameraWithLatitude(20.0,
            longitude:20.0, zoom:6)
        let mapView = GMSMapView.mapWithFrame(CGRectZero, camera:camera)
        let marker = GMSMarker()
        marker.position = camera.target
        marker.snippet = "Hello World"
        marker.appearAnimation = kGMSMarkerAnimationPop
        marker.map = mapView
        self.view = mapView
      }
    }

  5. Fri Jan 22 04:41:43 2016

    You can use this Swift code:

    func playSound(soundName: String) {
        let soundURL = NSURL(fileURLWithPath: NSBundle.mainBundle().pathForResource(soundName, ofType: "mp3")!)
        let audioPlayer = AVAudioPlayer(contentsOfURL:soundURL)
        audioPlayer.prepareToPlay()
        audioPlayer.play()
    }
    
    @IBAction func buttonClicked(sender: AnyObject) {
        let soundArray = ["One"]
        playSound(soundArray[0])
    }

  6. Fri Jan 22 04:27:53 2016

    There is an updated version of the e-book at https://swiftlang.eu#book

  7. Fri Jan 22 01:26:40 2016
    niutech posted in Gmail API | Request a Message.

    From GTLQueryGmail.h:

    // Method: gmail.users.messages.get
    // Gets the specified message.
    //  Optional:
    //   format: The format to return the message in. (Default kGTLGmailFormatFull)
    //      kGTLGmailFormatFull: "full"
    //      kGTLGmailFormatMetadata: "metadata"
    //      kGTLGmailFormatMinimal: "minimal"
    //      kGTLGmailFormatRaw: "raw"
    //   identifier: The ID of the message to retrieve.
    //   metadataHeaders: When given and format is METADATA, only include headers
    //     specified.
    //   userId: The user's email address. The special value me can be used to
    //     indicate the authenticated user. (Default me)
    //  Authorization scope(s):
    //   kGTLAuthScopeGmail
    //   kGTLAuthScopeGmailModify
    //   kGTLAuthScopeGmailReadonly
    // Fetches a GTLGmailMessage.
    + (instancetype)queryForUsersMessagesGet;

    So you should add query parameters like:

    query.urlQueryParameters = ["identifier": id]

  8. Wed Jan 20 15:33:43 2016
    niutech posted in Load image from url.

    You can do it like this:

    let url = NSURL(string: combo)
    let data = NSData(contentsOfURL: url!)
    imgdisp.image = UIImage(data: data!)

  9. Wed Jan 20 15:26:30 2016
    niutech posted in how to learn swift .

    The best is to start with the Swift Language YouTube channel , where you will find the Stanford University Swift Course, Udemy Course, or 300+ other video tutorials on Swift.

  10. Mon Jun 15 16:22:35 2015
    niutech started the conversation Swift 2.0 at Apple WWDC 2015.

    Welcome back!

    Last week Apple introduced Swift 2.0 and announced that it will be open sourced later this year. This is great news!
    Have a look at the Swift sessions videos at WWDC 2015 .

View more