Administrator
Last active [hidden]
Swift 2.2 requires Xcode 7.3, which works in OS X 10.11+. I would recommend at least 4GB RAM.
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)") } }
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") }
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 } }
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]) }
There is an updated version of the e-book at https://swiftlang.eu#book
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]
You can do it like this:
let url = NSURL(string: combo) let data = NSData(contentsOfURL: url!) imgdisp.image = UIImage(data: data!)
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.
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 .