objective-c

Retain count in objective C return -1

I'm new to objective C, I have a NSMutableArray with 3 objects in it, then I try to print the retainCount of the array. Why the final retainCount return -1? Thanks NSLog(@"myArray has retain count of %d", [myArray retainCount]); [myArray release]; NSLog(@"myArray has retain count of %d", [myArray retainCount]); Result from console...

Custom Core Data accessors for transformable UILocalNotification

Hi there, I have a transformable attribute on one of my entities, called reminder. It's a UILocalNotification. Now, since I want to schedule it when it's added, and cancel it when removed, I would like to override the accessors to handle the scheduling and cancelling in there. How would that look? Thanks! ...

Cannot change UIButton origin

I'm trying to create a button programmatically and cannot change the origin. Here's the code: UIButton *newButton = [UIButton buttonWithType:UIButtonTypeCustom]; newButton.frame = CGRectMake(100, 200, 150, 50); [newButton setTitle:@"Hi There" forState:UIControlStateNormal]; [self.view addSubview:newButton]; The button shows up, but c...

Objective C (iOS) design question

Hi, I have a problem where the data is represented in form of a tree (Ex: binary tree). The tree has nodes of different kind. So basically, there is a base class and then different nodes are derived from it. This data also needs to be presented on the screen (to the user) and this involves custom drawing of each nodes. How the node is ...

UITabBarController - how to make "no tabs" selected at start up ?

Hi, Is there any way in iPhone to unselect all tabs of a UITabBarController ? ie, my application has a "homepage" which does not belong to any tabs on the below displayed tabbar. Now when user touches any tab on the tabbar, I would like to load the corresponding tab. Is this possible ? I have already tried: self.tabBarController.tabBar...

CALayer position contains NaN: [nan -0.5]

I see this log in the console when I run my app: CALayer position contains NaN: [nan -0.5] The app consists of a UITabar of which the first tab is a UINavController. In the NavController I'm launching the AddressBookPicker. In the Addressbook picker I'm only choosing to show phone numbers. When I choose on a contact that has only email...

How to handle returned null from SQLite

Hi all, I am using this in a method: + (void) getA:(NSString *)dbPath { if (sqlite3_open([dbPath UTF8String], &database) == SQLITE_OK) { const char *sql = "select a from a_table"; sqlite3_stmt *selectstmt; if(sqlite3_prepare_v2(database, sql, -1, &selectstmt, NULL) == SQLITE_OK) { while(sqlite3_...

objective-c touch-events

I've got a set of Images and would like to know which I have touched. How could I implement that ? To be more precise: A "Home-Class" will instantiate a couple of Image-Classes: Image *myImageView = [[Image alloc] initWithImage:myImage]; The image-class looks something like this: - (id) initWithImage: (UIImage *) anImage { i...

Is there a better way to remove stopwords in objective c?

The method I am doing right now is breaking the string into array of words in NSSet and minus the set of stopwords. Is there a more efficient way? ...

My NSOpenGLView won't work. I've tried everything.

I want to display something in an NSOpenGLView, but since there is a total of zero bytes of documentation on it, and the sample code is as big and complex as the documentation should be, I can't get any wise out of it. This is my code so far, and my ANOpenGLView is an NSOpenGLView in a NIB subclassed as ANOpenGLView: @implementation ANO...

Can I play loops using Audio Toolbox?

hello all, in my app i use AudioToolbox framework and i need to play a loop can i ? this is the AVAudioplayer code that goes slowly with 2 touches simultaneously - (AVAudioPlayer *)getNoteFromFilename:(NSString *)name andoftype:(NSString *)type{ NSString *soundPath = [[NSBundle mainBundle] pathForResource:name ...

Changing the tab bar title of the moreNavigationController from "More" to a custom

Hi there, is there a way to change the title in the tabbar of the moreNavigationController? It always shows "More". I tried it with setting the moreNavigationController.tabBarItem.title, unfortunately it seems to have to effect. Sincerely, Heinrich ...

Ignoring the users default language/locale and set an own?

Hi, is it possible to set a locale for the app with no regard to the users language? My motivation is that I don't want the automatically translated labels of some buttons. Sincerely, Heinrich ...

implementing protocol methods in objective-c

If I have an protocol (say UIPickerViewDataSource) and I implement its required methods, do I need to declare those methods in the header file of my class? At the moment I'm not doing so and I get a warning of incomplete implementation (although everything works fine). If I do add the required methods in the then I don't get such warnin...

Save a set of integers iPhone

Hi In my game I want to save a set of integers as statistics players can view. E.g number of deaths. This is an int I simply increase by one each time they get a game over. How can I save this then have it at that number when I relaunch the game? Thanks. EDIT: Ok after reading a few answers Im thinking writing to a plist is the way ...

assign value from array to string.

hi all, i have an array of 5 objects. i want to assign object which is at index 1, to an NSSTRING. nsstring *abc = [array objectAtindex:1]; i know this is wrong syntax, this is returning object , something like this. how can i get value which is at index 1 and assign it to an string? regards ...

Regex to retrieve string

I wish to match &amp;v= and before "> is there a regex match i could use Example: <a accesskey="1" href="/watch?gl=GB&amp;client=mv-google&amp;hl=en-GB&amp;v=ubNF9QNEQLA">Test Your Awareness : Whodunnit?</a> i only need the ubNF9QNEQLA Thanks ...

What is PyObjC?

I understand the concept of PyObjC, but can nowhere find any information on what exactly it is or how to get started with it. Is it like a converter, where youinput python files and get an objective c one? Or is it a library you can import to your objective c files which let's you write python in them? Or is it something else entirely?...

iphone uiaccessiblity multiple languages

I've been doing reading about VoiceOver on iPhone, but I can't find anyone talking about how to mark content as a certain language and use more than one language in an app. I want to make my dictionary VoiceOver compatible. For example this can be written in a UITableViewCell (English then German) and VoiceOver will read this line wi...

Where should I perform a Reachability check?

I want to check for a valid network connection. I followed Apple's Reachability example and put my check in applicationDidFinishLaunching #pragma mark - #pragma mark Application lifecycle - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { if(getenv("NSZombieEn...