Tag: cocoa touch

UITableView Core Data reordering

I know this question has been asked before, and I took a look at the answer to this question. However, I’m still confused as to how to implement reordering with a UITableView in a Core Data project. What I know is that I need to have a “displayOrder” attribute in my Entity to track the […]

How to scroll UITableView to specific position

How can I scroll the table’s cell to specific position ? I have a table which shows 3 rows (according to height). what I want is if I click on 1st row than according to table’s height the 1st row should scroll and get new position (center) and same for other rows. I tried contenOffset […]

How can I convert my device token (NSData) into an NSString?

I am implementing push notifications. I’d like to save my APNS Token as a String. – (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)newDeviceToken { NSString *tokenString = [NSString stringWithUTF8String:[newDeviceToken bytes]]; //[[NSString alloc]initWithData:newDeviceToken encoding:NSUTF8StringEncoding]; NSLog(@”%@”, tokenString); NSLog(@”%@”, newDeviceToken); } The first line of code prints null. the second prints the token. How can I get my newDeviceToken as an […]

UIActionSheet cancel button strange behaviour

I have a UIBarButtonItem opening an action sheet to offer users choices about what to do. Everything works as expected unless I try to click on the “Cancel” button. The target of the button appears to have moved up from where it should be. I can only activate it by clicking somewhere in the middle […]

How do I convert NSMutableArray to NSArray?

How do I convert NSMutableArray to NSArray in objective-c?

Getting an array of a property from an object array

I need to extract an array of a single property from a custom object array. eg. @interface MyClass : NSObject { int sampleNumber; NSString *sampleName; } I have an array of MyClass instances called myArray. I want to then get an array of the sampleName strings. Is there a way to do it without stepping […]

Why is 'no known method for selector x' a hard error under ARC?

Maybe it’s useful if calling a method that MyClass doesn’t understand on a something typed MyClass is an error rather than a warning since it’s probably either a mistake or going to cause mistakes in the future… However, why is this error specific to ARC? ARC decides what it needs to retain/release/autorelease based on the […]

Transitioning to landscape rotation within a uinavigationcontroller

I want to push a landscape view from within a uinaviagtioncontroller, whose initial view is in portrait… So you click a button, or tableviewcell, and the screen rotates 90° into the new view.. How would I manage that? This is similar to how the Youtube app works when transitioning from movie info screen to the […]

Shifting view after displaying modal – possibly AutoLayout related

I present a simple view with a couple of labels and a button, all inside a UIScrollView and laid out using auto layout. The button presents another view, which includes a navigation item for dismissal. After dismissal, though, the content of the original UIScrollView is offset. Strangely, the amount by which it is offset seems […]

dispatch_sync() always execute block in main thread

Is there any difference between if dispatch_sync is called in 3 different queue like 1. dispatch_sync(dispatch_get_main_queue(),^(void){ NSLog(@”this execute in main thread”) // via [NSThread isMainThread] }); 2. dispatch_sync(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^(void){ NSLog(@”this also execute in main thread”) // via [NSThread isMainThread] } 3. dispatch_queue_t queue; queue = dispatch_queue_create(“com.example.MyQueue”, NULL); dispatch_sync(queue, ^(void){ NSLog(@”this also execute in main […]