objective-c

UIMenuController in custom UITableViewCell

I have a tableview that uses a custom UITableViewCell. In the cell, I have a button that shows a custom menu controller with three menu items. I would like to push a new view controller when you click the 'See Detail' button. I have this run when the 'See Detail' button is clicked in the custom cell - (void)seeDetail:(UIMenuControlle...

removeFromSuperview crashes when called on UIScrollView and UIScrollView crashes when scrolling past the right end.

Hello. In my program I have this code: @try{ if (online_scores_pages != nil){ NSLog(@"Here - %@",online_scores_pages); }else{ NSLog(@"NIL"); } [online_scores_pages removeFromSuperview]; NSLog(@"Here 2"); [self becomeFirstResponder]; NSLog(@"Here 3"); section = CURLING_MENU; }@catch (NS...

objective c memory management

How do you release the memory in this situation? Do you have to? - (NSString *) whatHappensHere { NSMutableString * mutableString = [[NSMutableString alloc] initWithString:@"Hello"]; // .... // more code ... // ... return mutableString; } ...

Convert NSString to NSNumber

Hi, i get a nsstring from a nsdictionary via: inputString = [dataUsage valueForKey:@"amount"]; after that the string looks like: 23,56 how can i convert this string into a nsnumber? i have tried the following: NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init]; [formatter setNumberStyle:NSNumberFormatterDecimalStyle];...

Argument comparison order

I'm a seasoned programmer and therefore feel a little embarrassed asking this question but decided to do so anyways. I'm reading this book, and have also seen various examples across the net where the order of arguments in a compare operation is reversed and I wonder if there is a reason for it, or just because it looks "cool" and does ...

Hide iAds on iPhone when there is no network connection

Hey All, I am trying to include iAds in my app. It works fine when there is network connection but the iAds doesn't hide when the network is not available..please find the code below and help me..thanks for your time.. I included this code in viewDidLoad static NSString * const kADBannerViewClass = @"ADBannerView"; if (NSClassFromStr...

How to stop the UITextField from responding to the shake gesture?

By default, if you shake the iPhone while entering text in a UITextField, a little box will appear asking if you want to undo typing. How can I prevent this from happening? I looked through the UITextField, UITextFieldDelegate, and UITextInputTraits docs and found nothing relating to shaking. Presumably I could subclass UITextField to i...

KVC string conversion not working for BOOL value.

Hey. I am reading in a string from a file and attempting to use the resulting string to set a BOOL property on an object using the KVC method -setValue:forKeyPath:. However, this breaks with an exception: -[NSCFString charValue]: unrecognized selector sent to instance 0x7fff711023b0. I'm guessing this is because BOOL is typedef'd from...

Looping a CFRunLoopSource

Here is the source files I'm currently developing. The idea behind this class is to contain a target object and selector which will be invoked in whatever CFRunLoop passed to scheduleInCFRunLoop. I need this to loop repeatedly without consuming all available processing time on the iPhone. Any help on completion will be most helpful, I've...

Connecting Java to Objective-C (using AsyncSocket)

I need to communicate between a Java app (desktop) and an iOS app. I've decided to use AsyncSocket on the iPhone side (and I've gotten data sending to work). For this question, I'm just running the EchoServer demo app on OSX 10.6.4. Source code is here. Here's my Java code, boiled-down: Socket echoSocket = new Socket("192.168.0.102...

Doxygen document functions

Hey guys, I am programming in objc and am documenting my stuff with doxygen. Unfortunately it is not documenting my c functions only my classes and their methods. I have them defined in a .h like so: /// Returns whether the current machine is little endian based. BOOL littleEndian(void); and then I have them implemented in a .m. Does ...

NSTask with bash script problem

For example, i have this simple bash script: #!/bin/sh cd $1; And this cocoa wrapper for it: NSTask *cd = [[NSTask alloc] init]; NSString *testFolder = [NSString stringWithString:@"/Users/test/Desktop/test 1"]; [cd setLaunchPath:@"/bin/sh"]; [cd setArguments:[NSArray arrayWithObjects:[[NSBundle mainBundle] ...

Translation error

NSString *soundURL = [NSString stringWithFormat:@"http://translate.google.com/translate_tts?q=%@&tl=%@",strTextOfFilter,strCodeOfLanguage]; NSLog(@"URL : %@",soundURL); this show:http://translate.google.com/translate_tts?q=%E4%BD%A0%E5%A5%BD&tl=zh-TW copy url to Browser of firefox. it's right Translation of Chinese,b...

Core Data database doesn't save

I'm trying to implement the Paparazzi 2 assignment from the Stanford CS193 course and I'm running into a problem. My one call to save the database is when the app exits (I'm borrowing heavily from Mike Postel's version to check my code): - (void)applicationWillTerminate:(UIApplication *)application { if (flickrContext != nil) { ...

Application:openFiles: separate files by groups

I need that my application detect how many files has been dropped to it dock icon. For this i use application:openFiles: method - (void)application:(NSApplication *)sender openFiles:(NSArray *)filenames { NSLog(@"%d",[filenames count]); } But unfortunately files sometimes separates by group. So, for example i dragged 3 files to dock...

NSPredicate that references multiple fields on a to-many relationship?

I'm using a SQLite persistent store. I have a NSManagedObject class Den with a to-many relationship Bear. Bear has several fields: Bear: breed color age ... When I am building fetch requests for my Foo objects, I can filter to objects that have a related Bear with a certain field value: NSPredicate *hasGrizzlyPred =...

NSMutableArray 'addObject:' Crashing iPhone App

This is my error: Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayI addObject:]: unrecognized selector sent to instance I have no idea why this is happening. Both the array (which is NSMutableArray) and the object being added are definitely not nil, and the @property for the array is straig...

How can I make a status-bar only Mac application?

I'm very new to developing for the Mac, and I'm trying to write a Cocoa application whose only presence is in the system menu bar, and does not appear in the Dock. Dropbox, Alfred, and Quicksilver do this (or can be configured to do this). Thank you. ...

Executable file in xcode

How to get the executable files from the xcode ...

Default User Settings in iOS4

I have a Settings.bundle and default settings in it. I try to read it: NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; [defaults synchronize]; NSString *fontSize = [defaults objectForKey:@"fontSize"]; but it always null If I don’t run the Settings application before my application runs for the first time. How...