Before I start, I just wanted to say that I am very new to application development in general, I have been doing this for only a month, so do not be shy, as far as possible, haha.
Okay, that's why I'm working on a quote application, so I created an array that I can access from any controller. This will contain the “liked” quotes that are added from another view.
Here is my global "liked Array". It is in its own fast file.
import Foundation
struct Globals {
static var likedArray: [String] = ["Touch 'Liked' To Continue..."]
}
Quotes are added to your favorite Array by this method, from another view controller file.
@IBAction func likedbuttonPressed(sender: AnyObject) {
Globals.likedArray.append(quoteLabel.text)
}
And the “liked” quotes are shown in another view using this method
@IBAction func likedButtonTouched(sender: AnyObject) {
self.favouritesLabel.fadeOut(completion: {
(finished: Bool) -> Void in
self.currentlikedArrayIndex++
if self.currentlikedArrayIndex < Globals.likedArray.count {
self.favouritesLabel.text = Globals.likedArray[self.currentlikedArrayIndex]
} else {
self.currentlikedArrayIndex--
}
self.favouritesLabel.fadeIn()
})
}
, , , .
, : ?
, . .