objective-c

objective-c getters/setters & variable/property declarations--an easier way?

hopefully this is an easy one. I'm coding in objective-c and i'm wondering if there are any tools/tricks (anything) that you use for this annoyance (see below). Is there an easier way to declare variable/properties within the header and implementation files? e.g., I'm not a big fan of typing this in the header: NSString *commercial...

Does NSAutorelease need to be the first line in main?

Just curious does NSAutoreleasePool need to be right at the top of main, or can you declare variables before it? int main (int argc, const char * argv[]) { int myNumber; int myOtherNumber; NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; [pool drain]; return 0; } cheers -gary- ...

Read only a portion of a file from disk in objective-c

I am reading a very large file using a NSInputStreamer and sending them to a device in packets. If the receiver does not get a packet, I can send back to the sender with a packet number, representing the starting location in bytes of the packet missing. I know an NSInputStreamer cannot rewind and grab the packet, but is there another w...

iPhone - parsing nsdata to get multiple files stored there.

I'm trying to find a the new line and returns that are inside a nsdata object that I'm parsing . Here's some code: uint8_t *arr = [receivedData bytes]; NSUInteger begin1 = 0; NSUInteger end1 = len; uint8_t *arr1 = (Byte *)malloc(sizeof(Byte)*((end1-begin1+1))); int j = 0; for (int i = begin1; i < end1; i++){ ...

How can I customize a twitter client in objective c

Hi Folks, I am designing a twitter iPhone app for my school. I wanted to moderate the users who can access the school account. In simple terms i do not want to use the original twitter server but make it local to only few users. Simply lets say a twitter for class. This will be running on our server and only few people can access it. I ...

NSTableView Troubles

Hey everyone, I'm working on learning Objective-C/Coaoa, but I've seem to have gotten a bit stuck with getting the NSTableView object to work for me. I've followed all the directions, but for some reason I still get this error: Class 'RobotManager' does not implement the 'NSTableViewDataSource' protocol Here's my source, tell me what...

Elevating to admin rights in Mac application

I am making a simple application that lets you quickly enter a shell command to be run. It works perfectly, however there is the problem of sudo commands. Currently, it detects a sudo command, and then I try and get it to bring up an authorization window for the user's password, exactly like you would see in Installer. Here's the code o...

In Xcode, project settings, how to add relative path?

How it looks? thanks ...

iPhone - UILabel containing text with multiple fonts at the same time

I am looking for a way to use a UILabel (or something similar) to display something like this: Tom: Some message. It is like how it's done in for example the Facebook app to display the "what's on your mind?" messages. Does anyone have any suggestions how to approach this? ...

How to run iPhone program with Zombies instrument?

I'm running XCode 3.2 on Snow Leopard and I'm trying to run the Zombies instrument against my app but the selection is grayed out and I don't know why. I know about the NSZombieEnabled environment variable. I have that set to YES on my application. I'm not sure if this matters, but, the app is an app that I started developing on Leopard ...

Encrypted NSData to NSString in obj-c?

I have an iPhone app which encrypts an inputted NSString using CCCrypt (AES256) and a plaintext key. The string and key are given to the encryption method which returns an NSData object. Requesting [data description] where 'data' is the encrypted string data gives an NSString like: "<0b368353 a707e7de 3eee5992 ee69827e e3603dc2 b0dbbc0b...

My delegate's methods never get called when I use connectionWithRequest:delegate.

I'm making an asynchronus POST request in an iPhone app with this call: [NSURLConnection connectionWithRequest:req delegate:self]; The request seems to get to the server just fine, but none of the delegate methods get hit. I've implemented: - (void)connection:(NSURLConnection *)connection didCancelAuthenticationChallenge:(NSURLAu...

NSDocument architecture pros and cons

Does anybody have any NSDocument pros and cons they'd like to share? In particular: Once you depend on the NSDocument architecture, is it difficult to refactor it out if you need to? Are there performance implications? Does it limit you in certain/many ways? ...

NSFetchedResultsController with search

What is the best practice to filter the NSFetchedResultsController data? do i need to re-initialize it every time the searchbar's text changes? I am using a UISearchDisplayControllers and i'm implementing: - (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString; ...

Why am I seeing the "Nested functions are disabled" error?

Hey there, I'm sort of new to Objective-C, and well, programming in general. I have a little experience in C# and c++, to give you a bit of a background. I'm using Xcode to create a simple application that adds 2 fields and returns a sum, and I've narrowed it down to one error: "Nested functions are disabled, use -fnested-functions t...

Class Instance Release Order?

This is probably a pretty basic question, but just something that I wanted to make sure I had right in my head. When I release the class instance "newPlanet_001" what is the order of disposal, Am I right in assuming that if the retain count of the object is 1 prior to the release that the instances dealloc method is called first (to rel...

Set pointers to nil after release?

After releasing objects is it best to set the pointers to nil? Thats what I have been doing, just wanted to ask if its necessary, good practice or overkill? - (void)dealloc{ [planetName release]; // NSString instance variable [super dealloc]; } @end . - (void)dealloc{ [planetName release]; // NSString instance variable ...

C definition formatting question

I am thinking about changing my formatting style. I have been doing this: char *foo(IULabel *label, char *buffer) { UITextView *tv; int i; int *j; ... } and I am thinking that it might be easier to understand if I were to write: char * foo(IULabel * label, char * buffer) { UITextView * tv; in...

Button not working

Hey there, I'm a designer thats really new to programming with xcode or Objective-C in general. I'm trying to create a few simple apps to try to get a better hang on programming the iPhone. Currently, I'm working on a very basic app which has 3 textfields, a name field and two number fields, and when you click the button, it shows in the...

Objective-C Warning

I am fairly new to objective-c and am having trouble understanding the warning message for the following block of code: void PrintPathInfo() { NSString *path = @"~"; NSString *message = @"My home folder is: "; NSLog([message stringByAppendingString: [path stringByExpandingTildeInPath]]); } This is the warning message I a...