Tag: objective c

Converting NSString to Base64 Data for XML Serialization

I use Apple’s NSXMLParser class to load data. I have a separate framework for serializing my data. I’ve had enough of the long dash, the Word quotes, etc. showing up in my XML output and causing errors when parsing, which often result in data loss due to the parser’s poor handling of those characters. If […]

Why do argument lists in certain Cocoa methods end with a nil?

Why do argument list in some methods end with nil? I have noticed this particularly in the collection classes, for example NSSet: mySet = [NSSet setWithObjects:someData, aValue, aString, nil]; and NSArray: NSArray *objects = [NSArray arrayWithObjects:@”value1″, @”value2″, @”value3″, nil];

Is objective C 2.0 a proper superset of C?

I’ve heard that objective-C is a proper superset of C, but is objective-C 2.0? The reason I ask is that either it isn’t, or I misunderstand the phrase ‘proper superset’, because this code is valid C syntax: #import <stdio.h> int main () { char *nil = “hello”; printf(“%s\n”,nil); } But does not compile in Objective-C […]

NSTask launch path not accessible

I am using the following code in my Cocoa project to call a script I made. The script is in the same folder as the project and even shows up under the “Resources” folder in XCode. The proper path is found, but it still says that the path is not accessible. Help please. NSBundle *mainBundle=[NSBundle […]

When using hidesBottomBarWhenPushed, i want the tab bar to reappear when i push another view

I have a navigation controller. For one of the views i want to hide the bottom tab bar, so it gets the max possible screen real estate. To do this, i have: – (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { self.hidesBottomBarWhenPushed = YES; // To hide the tab bar […]

How can I disable/enable UISearchBar keyboard's Search button?

I am using UISearchBar in my code. I have imported its delegate in header file and implemented some delegate methods in implementation file also. When we tap on the UISearchBar, a keyboard will appear to enter text. The return key of the keyboard is “Search” button. It will disabled by default. When we enter a […]

How to identify timezone from longitude and latitude in iOS

How can I find out which NSTimeZone a given longitude and latitude fall in?

What kind of logarithm functions / methods are available in objective-c / cocoa-touch?

I’ve tried searching for logarithm + objective-c, but all I get is math test pages from teachers, or explanations what a logarithm is 😉 I’ve got some measurements that are like 83912.41234 and others are 32.94232. I need to press down this huge spectrum into something between 0 and 100, and that 32.94232 would habe […]

How can I determine which objects hold references to other objects that are causing memory leaks in objective-c?

I have tried using the leaks tool, and “analyze” etc to find the leak, but it can’t find it. Using allocations I can determine the objects which are not being released. I have noticed (by adding debugging statements in the dealloc method), that dealloc is not called for these objects. How can I determine which […]

Why does MPMoviePlayerController setCurrentPlaybackTime goes to the wrong time?

I am experience some weirdness with MPMoviePlayerController. I am trying to set the currentPlaybackTime of a video whilst it is playing (file source). Here is an example of what happens Play video hit button to jump to 9.3 seconds into the video Play state changes as follows: a) Play state = 5 (MPMoviePlaybackStateSeekingBackward). currentPlaybackTime = […]