ios8

Multiplying ints in swift

让人想犯罪 __ 提交于 2019-12-24 13:50:30
问题 I am new to swift and iOS programming and learning slowly here. So I have: @IBOutlet weak var timeEntered: UITextField! @IBAction func countDown(sender: AnyObject) { var total = timeEntered.text.toInt() total = total *7 } The line total = total *7 gives me the error "Consecutive statements on a line must be separated by a ;" I read here that you should do ( I don't know why but...) total = total! *7 And still I get the same error. Any help would be highly appreciated. Thanks! 回答1: I think

Swift NSLocale Simulator iOS 8

狂风中的少年 提交于 2019-12-24 13:25:12
问题 I'm having an issue with Swift and the iOS 8 Emulator in XCode 6.1. Indeed when I try to use NSLocale, almost every functions of it return nil. Here is how I use it: let cc = "fr" // Example let locale = NSLocale.currentLocale() let countryName = locale.displayNameForKey(NSLocaleCountryCode, value : cc) println(countryName) // Shows : nil It does work on device, iOS 7 and iOS 8 and on simulator iOS 7. It doesn't work on simulator iOS 8 and on Playground, it even EXC_BAD_ACCESS. I guess it's

Converting Object to JSON String For POST Request

时光怂恿深爱的人放手 提交于 2019-12-24 12:16:01
问题 I have an object that is an instance of a class similar to this: class MyClass { let aString: String let bString: String var cArray = [AnotherClass]() init etc... } AnotherClass is something like: class AnotherClass { let aInt: Int let bInt: Int var cFloat = Float init etc... } Ok, now i need to pass that object (instance of MyClass) as a POST request string parameter with the following format: { "aString": "1", "bString": "yannis", "cArray": [ { "aInt": 1965887, "bInt": 36513032311523,

Alamofire Request not getting executed

强颜欢笑 提交于 2019-12-24 11:36:33
问题 Something strange is happening. I have two ViewControllers A & B. In both of them I have imported Alamofire using below command import Alamofire ISSUE: I am calling exactly the same Alamofire Request in both controller. In VC - A it executes, in VC - B --its just not executing..There is no error or anything. When I debug using breakpoints, the entire Alamofire code is getting skipped for some reason. Can't seem to figure out why. Below is my Alamofire Code (THIS IS SAME in BOTH Controllers A

MPMoviePlayerController - Exit, detect movie play and iAd

守給你的承諾、 提交于 2019-12-24 11:27:52
问题 I have successfully integrated a working movie player with a pre-roll iAd video! Thanks to @Daniel Storm. However, I want information on how to exit the movie when the movie is finished or when the ad is finished. (exit means remove from the view), Also detect if the user has watched the ad. If there is internet connection failure or iAd failure, how can i detect if the pre-roll ad did not play. I am making a game, and if a user decides to get more coins, that person must watch an ad. If they

Deinit not called on Show Detail segue

两盒软妹~` 提交于 2019-12-24 11:22:44
问题 I encountered this issue on a larger Swift project, but was able to replicate it with a very basic project. I have the following view controller class: class ViewController: UIViewController { deinit { println("Deinitializing") } override func viewDidAppear(animated: Bool) { NSTimer.scheduledTimerWithTimeInterval(0.1, target: self, selector: "segue", userInfo: nil, repeats: false) } func segue() { self.performSegueWithIdentifier("segue", sender: self) } } My storyboard is configured so there

Constraint controls greyed out in Xcode (pinning toolbar to bottom)

ぃ、小莉子 提交于 2019-12-24 10:55:24
问题 I have a toolbar that I want to pin to the bottom. I was trying to use Storyboard rather than code to do it. When I command + drag from the toolbar to the controller, all I get is a delegate option rather than the option to pin to each other. How do I add constraints to pin this toolbar to the bottom of the view controller? Here's my updated view controller flow. Not sure if I need the second navigation controller. 回答1: So it looks like you want a table view and a toolbar in the same window.

UIWebView breaking constraint when playing a video in fullscreen (Xcode 6)

我是研究僧i 提交于 2019-12-24 07:08:09
问题 I'm updating an iOS app for an YouTube channel. In the previous version (iOS 7 using Xcode 5), I used to embed youtube iFrame in a UIWebView and everything would work just fine. However, in iOS 8 using Xcode 6, every time I play a Youtube video and it goes full screen, my UIWebView constraints break and UIWebView gets relocated in my Controller (usually goes 10 points up in the screen). I've tried to change the constraints but it seems that doesn't matter what constraint I set up, it will

SKLightNode not working on real device [iPhone 5]

旧街凉风 提交于 2019-12-24 05:37:38
问题 I've set up a minimalistic project here which simply adds a red square and - after tapping the screen - a light source lighting it. On simulator it runs fine, but on my iPhone 5 the square just becomes invisible as soon as the light source gets added to the node tree. Can anyone test this on other, real devices and give feedback? Any solutions? It's driving me crazy. Here's the scene's code: SKLightNode* lightNode; @implementation GameScene -(void)didMoveToView:(SKView *)view { //Add some

How to differentiate if NSData is xls, ppt or doc on objective c

泪湿孤枕 提交于 2019-12-24 04:30:34
问题 I'm working on a File-Handling type of app, I recently encountered a bug that is caused by links that doesn't have a file extension like this: https://drive.google.com/uc?export=download&id=1234567abcdefghijk I've been basing the file type by the filename located at the end of the link which is the direct link to the file. In the case of a redirecting link like the google drive link above, it still returns the data but the problem is since it doesn't have a file extension, the UIWebView doesn