nsuserdefaults

Swift: Insert Alert Box with Text Input (and Store Text Input )

对着背影说爱祢 提交于 2019-12-03 10:11:54
In one of my viewController , I want to make an alert box appear that prompts the user to type this information.Then, I want the user to store this input using NSUserDefaults . How can I achieve this? Thank you in advance! Andrei Papancea Check this out: let alertController = UIAlertController(title: "Email?", message: "Please input your email:", preferredStyle: .alert) let confirmAction = UIAlertAction(title: "Confirm", style: .default) { (_) in guard let textFields = alertController.textFields, textFields.count > 0 else { // Could not find textfield return } let field = textFields[0] //

Cannot compose tweets with Twitter Kit 3

匿名 (未验证) 提交于 2019-12-03 09:58:14
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I followed instruction from https://dev.twitter.com/twitterkit/ios/compose-tweets to compose tweets via my Object C app for iOS 11 // Objective-C TWTRComposer *composer = [[TWTRComposer alloc] init]; [composer setText:@"just setting up my Twitter Kit"]; [composer setImage:[UIImage imageNamed:@"twitterkit"]]; // Called from a UIViewController [composer showFromViewController:self completion:^(TWTRComposerResult result) { if (result == TWTRComposerResultCancelled) { NSLog(@"Tweet composition cancelled"); } else { NSLog(@"Sending Tweet!"); } }]

What is the correct way to save NSUserDefaults when my app is terminated on iOS

荒凉一梦 提交于 2019-12-03 08:53:06
I need to save my NSUserDefault when my app is completely quit in iOS. not didenterbackground and foreground . Only when user kill my app with minus(-) sign in iOS. So i write following codes in applicationWillTerminate of AppDelegate . - (void)applicationWillTerminate:(UIApplication *)application { [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"iCloud"]; [[NSUserDefaults standardUserDefaults] synchronize]; } But it doesn't save to NSUserDefault . So where should i write to save my data? From Apple Doc : For apps that do not support background execution or are linked against iOS 3

How to save data with NSUserDefaults using data from NSMutableArray

拈花ヽ惹草 提交于 2019-12-03 08:46:32
My NSMutableArray is declared in my .h file like this @property (strong, nonatomic) NSMutableArray * numbers; How do I use the NSMutableArray to save the data that is inputed to save to NSUserDefaults All help is appreciated Thanks in advance code in .h file @property (retain, nonatomic) IBOutlet UITableView *myTableView; @property (strong, nonatomic) NSMutableArray * numbers; code in .m @synthesize myTableView, numbers; -(void) viewDidLoad { NSUserDefaults *defaults=[NSUserDefaults standardUserDefaults]; [defaults setObject:numbers forKey:@"numberArray"]; NSMutableArray *resultArray =

Is There A Way To Get Notified When Someone Makes An In-App Purchase?

匿名 (未验证) 提交于 2019-12-03 08:35:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'd like to be notified when someone makes an In-App Purchase in my App rather than wait until the next day to check iTunes Connect to see wether or not I had any sales. Does anyone know of a way to do this? If not, it would be really cool! Thanks 回答1: Track StoreKit Purchase Events When a purchase takes place, send yourself a datapoint ( Track here... ) func paymentQueue(_ queue: SKPaymentQueue, updatedTransactions transactions: [SKPaymentTransaction]) { for transation in transactions { switch transation.transactionState { case .purchased:

NSUserDefaults errors in logs

匿名 (未验证) 提交于 2019-12-03 08:33:39
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I get some error messages in logs [User Defaults] Failed to write value for key GameId in CFPrefsPlistSource<0x1740faf00> (Domain: xxx.xxxxxx, User: kCFPreferencesCurrentUser, ByHost: No, Container: (null)): Path not accessible, switching to read-only [User Defaults] attempt to set <private> for key in <private> in read-only (due to a previous failed write) preferences domain CFPrefsPlistSource<0x1740faf00> (Domain: xxx.xxxxxx, User: kCFPreferencesCurrentUser, ByHost: No, Container: (null)) What does cause this? That's how I use

Using ARC and UITableViewController is throwing Observation info was leaked, and may even become mistakenly attached to some other object

匿名 (未验证) 提交于 2019-12-03 08:30:34
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I cannot seem to figure out what to do to resolve this error that I am receiving. I click on a cell which pops a new UITableViewController onto the stack. Once I hit the back button on the Navigation UI when in this controller I receive this error in the debugger but there doesn't seem to be any issue with the app as it doesn't crash or hang and still works fine. An instance 0x79a8400 of class UITableView was deallocated while key value observers were still registered with it. Observation info was leaked, and may even become mistakenly

crashes my app [NSMutableArray1 removeAllObjects] iphone sdk

匿名 (未验证) 提交于 2019-12-03 08:30:34
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: i use this code to check if any objects exist in my NSMutableArray if yes i remove them all but it crashes although there are objects why? if([NSMutableArray1 count]==1) { [poemoptionslist removeAllObjects]; } if ([NSMutableArray1 count]==0) { [poemoptionslist addObject: final1]; } CONSOLE OUTPUT 2010-10-18 03:42:13.166 app1[33398:207] * Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[__NSCFArray removeObjectAtIndex:]: mutating method sent to immutable object' * Call stack at first throw: ( 0

How do I find out the current keyboard used on iOS8?

天大地大妈咪最大 提交于 2019-12-03 07:58:19
问题 You can get a list of the keyboards installed on the iOS device using: NSUserDefaults *userDeafaults = [NSUserDefaults standardUserDefaults]; NSDictionary * userDefaultsDict = [userDeafaults dictionaryRepresentation]; NSLog(@"%@", userDefaultsDict); This yields something in the console like: { ... AppleKeyboards = ( "en_US@hw=US;sw=QWERTY", "es_ES@hw=Spanish - ISO;sw=QWERTY-Spanish", "emoji@sw=Emoji", "com.swiftkey.SwiftKeyApp.Keyboard" ); AppleKeyboardsExpanded = 1; ... } This tells me that

Way to persist MPMediaItemCollection objects? (selected from iPod)

走远了吗. 提交于 2019-12-03 07:44:39
I am making an app in which the user can select a song in a settings tab and have this played in a different view on demand. I want it so that this item can be stored if the user is to shut the app and reopen it another time. I have managed to allow the user to select and store a song in with: -(IBAction)showMediaPicker:(id)sender{ MPMediaPickerController *mediaPicker = [[MPMediaPickerController alloc] initWithMediaTypes: MPMediaTypeAny]; mediaPicker.delegate = self; mediaPicker.allowsPickingMultipleItems = NO; mediaPicker.prompt = @"Select Alarm Sound"; [self presentModalViewController