cocoa-touch

Geting day number from NSDate

孤者浪人 提交于 2020-01-24 01:07:29
问题 I need to get the day of the week from an NSDate as a number. For example, if today is Thursday I should get number 4, if Friday then number 5. Does this functionality already exist? 回答1: As per your requirement the following codes give you '4' for today i.e. Thursday 13 Dec 2012 NSMutableDictionary *weeks=[NSMutableDictionary new]; [weeks setObject:@"1" forKey:@"Monday"]; [weeks setObject:@"2" forKey:@"Tuesday"]; [weeks setObject:@"3" forKey:@"Wednesday"]; [weeks setObject:@"4" forKey:@

Passing integer between scenes, iphone game sprite-kit

蓝咒 提交于 2020-01-24 00:57:16
问题 I have a scene where the user chooses level in a game, then i want to switch to a game scene with the level the user chose. I want to create the game scene with the right level but to do this i need to pass an integer which is the level-number to the game scene so i know which level to load. My question is, how do i accomplish this? I have looked at the userdata property of nodes but could not figure out how to use it to accomplish what i want. Any help would be deeply appreciated. 回答1: When

Does iOS 4.3 support ARC

和自甴很熟 提交于 2020-01-23 17:52:06
问题 I tried googling but i was unable to locate the Apples Documentation where they say that ARC - automatic reference counting supports for iOS 4.3. Can someone tell me if this is true ? if so can you post me a link to apples documentation where it says so. 回答1: Transitioning to ARC: ARC is supported in Xcode 4.2 for Mac OS X v10.6 and v10.7 (64-bit applications) and for iOS 4 and iOS 5. Weak references are not supported in Mac OS X v10.6 and iOS 4. 回答2: Though ARC is in the new features list of

How can swap Row at fromIndex to toIndex in UITableView?

若如初见. 提交于 2020-01-23 16:44:09
问题 I created simple project with ARC , in which I have UITableView . And I have NSMutableArray of NSMutableDictionary . like ( { comment = ""; "field_name" = "field_name 1"; "main_id" = 1; "order_index" = 0; "picker_value" = ""; }, { comment = ""; "field_name" = "field_name 2"; "main_id" = 2; "order_index" = 1; "picker_value" = ""; }, { comment = ""; "field_name" = "field_name 3"; "main_id" = 3; "order_index" = 2; "picker_value" = ""; }, { comment = ""; "field_name" = "field_name 4"; "main_id" =

CoreData performFetch in viewDidLoad not working

和自甴很熟 提交于 2020-01-23 11:08:06
问题 When my main view controller is loaded and it calls viewDidLoad I am performing a fetch request and retiring an array or my core data objects: + (NSArray *)getData { // Fetch Data NSError *error = nil; if (![[[AppDelegate instance] fetchedResultsController] performFetch:&error]) { // Update to handle the error appropriately. NSLog(@"Unresolved error %@, %@", error, [error userInfo]); abort(); } NSArray *items = [[AppDelegate instance].fetchedResultsController fetchedObjects]; return items; }/

CoreData performFetch in viewDidLoad not working

荒凉一梦 提交于 2020-01-23 11:05:43
问题 When my main view controller is loaded and it calls viewDidLoad I am performing a fetch request and retiring an array or my core data objects: + (NSArray *)getData { // Fetch Data NSError *error = nil; if (![[[AppDelegate instance] fetchedResultsController] performFetch:&error]) { // Update to handle the error appropriately. NSLog(@"Unresolved error %@, %@", error, [error userInfo]); abort(); } NSArray *items = [[AppDelegate instance].fetchedResultsController fetchedObjects]; return items; }/

How can I manually rotate the keyboard (With animation)?

淺唱寂寞╮ 提交于 2020-01-23 08:30:07
问题 I have a controller that manages a UITextView. Normally, in an app that supports multiple interface orientations, I would simply override -shouldAutorotateToInterfaceOrientation: , set the appropriate auto-resizing masks, and go along my merry way. While going along my merry way, if I were to begin editing this UITextField in, say, portrait mode, then rotate the device to a landscape orientation, the keyboard would animate nicely to landscape mode along with the rest of the view. This is what

UIBarButtonItem Highlighted Color

独自空忆成欢 提交于 2020-01-23 06:22:07
问题 I have set a custom tint color for a UINavigationBar (within a UINavigationController ) which, in turn, sets an appropriate matching color for the UIBarButtonItems which are inserted into the UINavigationBar . However, when I select a UIBarButtonItem the button turns into (presumably) the highlighted state and presents a different color, which looks quite a bit out and does not nicely match the tint color. Is there a way to change this highlighted state color to a custom color? Ideally, I

Black background in UIView?

巧了我就是萌 提交于 2020-01-23 05:26:09
问题 I followed a tutorial online to draw in a subclassed UIView. The tutorial showed a UIView with a white background, I fixed this by simply changing the super's bg color. The problem is, when touches end, the background does not remain clear. I have no idea. I simply tried setting the fill color to [uicolor clearcolor]; unsuccessfully. Here is the code I am using: @implementation CachedLIView { UIBezierPath *path; UIImage *incrementalImage; // (1) } - (id)initWithCoder:(NSCoder *)aDecoder { if

Storing custom objects with Core Data

南笙酒味 提交于 2020-01-23 03:58:06
问题 I'm trying to store a NSMutableArray consisting of VOs (NameVO) with Core Data but getting the following exception thrown: 'NSInvalidArgumentException', reason: '-[NameVO encodeWithCoder:]: unrecognized selector sent to instance 0x1096400a0' My NameVO is just a simple value object, extending NSObject and contains two fields, a string and a NSMutableArray that itself contains strings. It also contains a compare function. I'm trying to prepare this to be stored as a CD transformable attribute