ios8

What is an “unwrapped value” in Swift?

允我心安 提交于 2019-12-17 02:06:11
问题 I'm learning Swift for iOS 8 / OSX 10.10 by following this tutorial, and the term " unwrapped value " is used several times, as in this paragraph (under Objects and Class ): When working with optional values, you can write ? before operations like methods, properties, and subscripting. If the value before the ? is nil, everything after the ? is ignored and the value of the whole expression is nil. Otherwise, the optional value is unwrapped , and everything after the ? acts on the unwrapped

Custom UITableViewCell from nib in Swift

邮差的信 提交于 2019-12-16 21:18:50
问题 I'm trying to create a custom table view cell from a nib. I'm referring to this article here. I'm facing two issues. I created a .xib file with a UITableViewCell object dragged on to it. I created a subclass of UITableViewCell and set it as the cell's class and Cell as the reusable identifier. import UIKit class CustomOneCell: UITableViewCell { @IBOutlet weak var middleLabel: UILabel! @IBOutlet weak var leftLabel: UILabel! @IBOutlet weak var rightLabel: UILabel! required init(coder aDecoder:

NSRange to Range<String.Index>

房东的猫 提交于 2019-12-16 19:54:53
问题 How can I convert NSRange to Range<String.Index> in Swift? I want to use the following UITextFieldDelegate method: func textField(textField: UITextField!, shouldChangeCharactersInRange range: NSRange, replacementString string: String!) -> Bool { textField.text.stringByReplacingCharactersInRange(???, withString: string) 回答1: The NSString version (as opposed to Swift String) of replacingCharacters(in: NSRange, with: NSString) accepts an NSRange , so one simple solution is to convert String to

iOS 8: setting background color UITableView via UIAppearance

梦想与她 提交于 2019-12-14 04:25:28
问题 i am used to doing the following to style all instances of UITableView : - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [[UITableView appearance] setBackgroundColor:[UIColor blueColor]]; return YES; } but on ios 8 this is not working anymore. for the purpose of testing and demo i created a new master-detail project using xcode 6.0.1 which you can find on github. running it on ios 7 works (table view gets blue background). on ios

UITextField no longer reloads keyboardType after reloadInputViews call

笑着哭i 提交于 2019-12-14 04:16:24
问题 In iOS 7, I could change the keyboard type while it is the firstResponder (on the fly): if (textField.text.length > 2) { textField.keyboardType = UIKeyboardTypeNumbersAndPunctuation; } else { textField.keyboardType = UIKeyboardTypeDefault; } [textField reloadInputViews]; // (Omitting some efficiency stuff to keep example to bare bones) This no longer works under Xcode 6/iOS 8. The documentations mostly reflect changes regarding custom keyboard. Using resign/become first responder is (still)

Access iPhone alarm from app?

可紊 提交于 2019-12-14 03:53:55
问题 Is there a way to access and update the native alarm settings in the iPhone from my app? I need to have a sliding alarm that changes based on the time of year and I want to use the native iPhone alarm for that. Is this possible in the iOS SDK, maybe asking the user for access to the alarm like when your app needs access to the camera or photos for example? 回答1: Unfortunately, I believe there is no public API for accessing the Clock app and settings. I think the reason for this is that Apple

Load file in Today extension

a 夏天 提交于 2019-12-14 03:42:40
问题 I've been trying to create a Today extension that needs access to a .plist file in the documents directory. I have setup the App group for both the app and the extension. While I have seen examples for NSUserDefaults , I couldn't find anything for accessing files. I tried accessing the file like this (which works in the app itself) let paths = NSSearchPathForDirectoriesInDomains( .DocumentDirectory, .UserDomainMask, true) let documentsDirectory = paths[0] as String let filePath = "\

crash on coredata ios8

旧城冷巷雨未停 提交于 2019-12-14 03:40:38
问题 I have a crash on CoreData when I save : 2014-09-16 09:51:58.273 My_app[2678:105246] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString appendString:]: nil argument' *** First throw call stack: ( 0 CoreFoundation 0x00000001087413f5 __exceptionPreprocess + 165 1 libobjc.A.dylib 0x00000001083dabb7 objc_exception_throw + 45 2 CoreFoundation 0x000000010874132d +[NSException raise:format:] + 205 3 CoreFoundation 0x000000010871274f mutateError + 159

How to resolve the ONLY_ACTIVE_ARCH=YES error in Xcode 6?

瘦欲@ 提交于 2019-12-14 03:21:59
问题 I am running a project in Xcode 6 ,I am facing this error can any one help to resolve the issue . I has changed valid architecture to armv7 armv7s arm64 then the issue not shown again , but i was getting other error for file while is not support for 64 bit. I am getting below errors "_OBJC_CLASS_$_OAAsynchronousDataFetcher", referenced from: objc-class-ref in LoginViewController.o "_OBJC_CLASS_$_OAConsumer", referenced from: objc-class-ref in SA_OAuthTwitterEngine.o objc-class-ref in

What constraints would prevent my UIViews from stacking on top of each other?

天涯浪子 提交于 2019-12-14 03:18:22
问题 My UIView's are stacking up on top of each other like so : Each UIView is inside a wordContainer . Each UIView has two UILabel 's inside of it I create each individual UIView with two child UILabel's like so : var labels = [UIView]() for word in words { let wordLabel = UILabel(frame: CGRectZero) wordLabel.text = word.valueForKey("sanskrit") as? String wordLabel.numberOfLines = 0 wordLabel.sizeToFit() wordLabel.translatesAutoresizingMaskIntoConstraints = false let englishWordLabel = UILabel