cocoa-touch

JSON and Core Data:Should I convert JSON into Core Data?

烈酒焚心 提交于 2019-12-24 14:43:08
问题 I'm new to Core Data and I need some help on my project. I'm developing iPhone app that get JSON (Restaurants info) from server and shows the location on the map and table view, and stores favorite restaurants by pressing "add favorite" button. For now, I'm just using NSDictionary and its functions to display data on the table and annotations and having favoriteRestaurant entity to store favorite restaurant data. However, I would like to convert the NSDictionary object into Core Data object

Stretch Drawn Shape to fit Frame?

我的未来我决定 提交于 2019-12-24 14:28:02
问题 I have an app where I'm drawing a special ellipse I made a via series of Bezier Paths as follows: CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSaveGState(context); CGMutablePathRef pPath_0 = CGPathCreateMutable(); CGPathMoveToPoint(pPath_0, NULL, 515.98,258.24); CGPathAddCurveToPoint(pPath_0, NULL, 515.98,435.61,415.54,515.98,258.24,515.98); CGPathAddCurveToPoint(pPath_0, NULL, 100.94,515.98,0.50,435.61,0.50,258.24); CGPathAddCurveToPoint(pPath_0, NULL, 0.50,80.86,100.94,0

How can I stop a stream when using STTWitter

白昼怎懂夜的黑 提交于 2019-12-24 14:26:39
问题 On iOS (but I think this would be just the same on OSX) I'm using STTWitter. Among other things, I want to use it to stream the main public timeline. I've successfully used getStatusesSampleDelimited:stallWarnings:progressBlock:stallWarningBlock:errorBlock: to start streaming tweets. How can I stop the stream once I've got enough, or want to switch to a different stream (e.g. streaming a search)? I've tried destroying the STTWitterAPI object - with no effect. I can't see a method on the

Removing non-selected items from UIPickerView

╄→尐↘猪︶ㄣ 提交于 2019-12-24 14:20:09
问题 I'm working on a nib file that has multiple UIPickerViews on it and as you can see below, it is extremely crowded. I basically want to make it clean and remove all of the "gray" items and just show the selected item. If you have any ideas that would make the page cleaner please share, this is more of a UI problem than a logic or code problem. Thanks in advance. 回答1: You dont need to add UIPickerView in there. You just add text field and set your UIPickerView as text field's input accessory

toolbar previous and next button logic

醉酒当歌 提交于 2019-12-24 13:58:53
问题 I'm using the following code to move to the next field using the UITextField delegate and also I'm adding a toolbar to the keyboard with the previous, next and ok buttons. The code is working fine. Like you see the keyboard return button logic is pretty generic, using the UITextField tags, and that's good because I'm gonna use the piece of code all around. Now I will need to write the previous and next buttons logic, and I'm lost. Any ideas? UPDATE (complete code, with some modifications,

Search nsarray of nsdictionary

牧云@^-^@ 提交于 2019-12-24 13:45:00
问题 I have an NSArray filled with NSDictionaries . One of the keys the dicts have in common is "name". I have another array, filled with names. I want to search the first array, if it finds a name it is supposed to add the dictionary to a third mutable array. The third array then contains all dictionary which names are in the name-array. 回答1: Use "fast enumeration", commonly also known as for-in loop: for (NSDictionary* dict in myArray) { Also, to compare NSString's, use -isEqualToString:. if ([

Does a UIView retain its view controller

巧了我就是萌 提交于 2019-12-24 13:04:28
问题 Does a UIView retain it's associated view controller? For example, in the following code the view is retained by the parent view. It would be handy if this view also retained its ViewController so that I could go ahead and release the controller in the loadView method. - (void) loadView { ... MyViewController* ctrl = [[MyViewController alloc] init]; [self.view addSubview: ctrl.view]; [ctrl release]; } The alternative, I suppose, is to keep track of the controller as an instance variable and

NSUserDefaults default value returning (null)?

好久不见. 提交于 2019-12-24 12:53:00
问题 This is probably something really simple that I am missing, why when using the code below to access settings does the default value return as (null) - (void)updateUIForDistanceUnits { NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults]; NSString *test = [userDefaults stringForKey:@"IDDistance"]; NSLog(@"DISTANCE: %@", test); } Root.plist 回答1: The default value in Root.plist is just what the UI shows if there's no value set, and you have to do the same in your code or set up

iOS capture event when youtube video ends or Done button pressed

痞子三分冷 提交于 2019-12-24 12:46:48
问题 I am displaying a youtube video on a uiwebview. When user selects it, fullscreen video starts as normal. Which event is fired when video ends or "done" button is pressed? I read some posts about it but suggested methods are now deprecated. View event will also be useful, for example if viewDidAppear is fired when video ends, but is not. Thank you 回答1: Implement your video to play inside MPMoviePlayerController if you can and then try below. Or else you could try below directly (but i havnt

NSPopover for iOS

时光毁灭记忆、已成空白 提交于 2019-12-24 12:12:11
问题 Is there something similar to NSPopover for iOS apps? It appears in the Object library for Mac but not for iPhone nor iPad, although I have downloaded apps using this (or at least some very similar) feature. So my question: Is there a legit way to implement this? 回答1: UIPopoverController is what you're looking for. 回答2: There is UIPopOverController , but its use is restricted to iPads: Popover controllers are for use exclusively on iPad devices. Attempting to create one on other devices