objective-c

How to detect unused methods and #import in Objective-C

After working a long time on an iPhone app, I realized that my code it's quite dirty, containing several #import and methods that are not called or useful at all. I would like to know if there's any compiler directive or way to detect those useless lines of code. Does Xcode have any tool to detect this? ...

Need formatting help for isEqualToString args

Code sample: NSString *title = [[NSString alloc]initWithFormat: @"%@", [self.answers valueForKey:idVor]]; NSString *message = [[NSString alloc]initWithFormat: @"%@",nameVor]; NSLog(@"%@", title); NSLog(@"%@", message); if([title isEqualToString:message]) NSLog(@"equal"); The vars title and message never respond to the if stateme...

Dynamically retrieving current method's name

I'd like to be able to put trace messages of the current class name and method name for all classes in my project. Is there a way to get the current method's name at run time, similar to: NSLog(@"classname: %@", [self className]); where self is a class derived out of NSObject? ...

coredata memory leak

Hi, I have a CoreDataHelper static class that consists of 2 static methods. I ran my project through Clang and didn't find any leaks, however running through Instruments shows a leak that looks like it's related to CoreData. I have basic knowledge of memory management in objective-c and I believe I'm following the rules. However, I als...

How to show a NSPanel as a sheet

I'm trying to show a NSPanel as a sheet. I'm naively doing something along those lines: SheetController *sheetController = [[[SheetController alloc] initWithWindowNibName:@"Sheet"] autorelease]; [[NSApplication sharedApplication] beginSheet:sheetController.window mo...

NSTask returning HTTP Headers

I'm running /usr/bin/perl or /usr/bin/php via an NSTask and want to retrieve the HTTP headers of the program. I've properly formatted the environment (Perl requires env vars to be prefixed with HTTP_), but neither of the task are returning anything other than raw output. I've been through the documentation on NSTask and the man pages f...

Read a txt file containing a matrix of numbers separated by spaces and lines into an array

I've been trying to read a txt file containing a formatted matrix (9x9) into an int array. The txt file is selected by the user using NSOpenPanel. An example txt file: 2 7 9 1 6 2 1 1 1 9 1 3 3 4 0 6 8 5 5 3 2 9 3 8 6 7 0 6 0 9 2 5 6 4 8 0 3 2 0 4 0 5 0 6 0 4 0 5 4 0 3 9 0 0 6 4 1 3 2 5 7 2 0 6 5 7 2 1 3 0 9 3 1 0 2 7 5 1 0 0 0 I...

Retrieving All Of An NSTreeController's Objects.

Bit of Background info, I'm using An NSOutlineView with Core Data. This Is What I'm trying to do: Retrieve All The objects from the Outline Views Tree Controller. Retrieve the 'name' Property (Core Data) from each of these objects as a String. Finally store the Strings of the 'name' Property from all the Objects in an NSArray. For ex...

iPhone: Writability of the Documents directory

Is there a way to write files to this directory remotely? I'm hoping it's possible to do via iTunes or whenever the iPhone is connected to a Mac/PC via USB. Could this be done with an iTunes plugin? If all else fails, is there an easy way to setup a WebDAV server on the iPhone? Thanks. ...

Accessor method object management?

After reading the Memory Management Guide I am trying to get my head around what is happening here My understanding "so far" is ... - (EngineClass *)engine { return [[engine retain] autorelease]; } I am returning a pointer to an Engine object. The retain count of the object is incremented to record we are making a new pointer to ...

Problems with a checkmark in a UITableViewCell

I have implemented this below code. UITableViewCell *cell = [tableView1 cellForRowAtIndexPath:indexPath]; UITableViewCell *cell2 = [tableView1 cellForRowAtIndexPath:oldIndexPath1]; cell.accessoryType = UITableViewCellAccessoryCheckmark; cell2.accessoryType = UITableViewCellAccessoryNone; oldIndexPath1 = indexPath; But, if I select an...

Checking for a valid delegate object before sending it a message.

I am trying to implement the delegate Pattern in Objective-C, however I am experiencing a Bad Access exception when invoking the delegate sometimes. It seems this is caused by the delegate being released. Apple does not recommend to retain delegates. How can I check my delegate if is still valid before trying to send it a message? ...

How to copy an object in objective c

I need to deep copy a custom object that has objects of its own. I've been reading around and am a bit confused as to how to inherit NSCopying and how to use NSCopyObject. Could someone help me out? Thanks for reading! ...

Class Composition Error?

I wonder if someone can explain where I am going wrong here, I am creating 2 objects (car & engine) where the car object contains a pointer to the engine object. I know I am missing the obvious or just making some silly mistake, but I can't quite put my finger on it. NB: the code all works, except for the line that is comment ERROR. //...

Objective C for beginners

I was just asked to talk about Objective C to a bunch of High School student for 20 minutes. They have no experience with programming at all. What topics should I cover? Should I define vocab such as Method, Class, Variable? Or should I do something else? Any comments are helpful! ...

Genre of application in iTunes

Hi, I am installing my own app in iTunes, and found it to be unknown genre. Since my app is an News based Genre, i need to make is shown as a news genre instead of unknown Genre. But my app is not yet launched in App store. whether this is the cause or anything else? please suggest Any help would be appreciated. -Sathiya ...

Dynamic uploading content in UINavigation Bar

Hi, In my application i am using UINavigation bar to display the logo of weather icon. But this weather icon needs to updated dynamically. At first i load the images and in text in the navigation bar and then i redirect the controller to UIViewController to load my application fully. After loading my applcation i need to update the ...

Launch a process from Objective-C on the desktop

We have a java app which we call with a parameter (a selected folder), which works fine in C#. However, I'm at a loose end to work out how to do this in Objective-C; I've found the LaunchApplication command, but it's a bit vague. Can someone please help me out? ...

Application that runs in background and bugs the user.. (on users request)

I need to launch a program that will at a users pre defined interval, open and bring to front a (preferrably very good looking) style window to ask the user to fill in some details. I have written some normal cocoa apps, but this seems to require some extra knowledge I dont have (: Where do I start? (And before anyone gets upset i might...

How do I prevent a one pixel border in variable height UITableViewCell from coming out as multiple pixels?

In my test app, I want to style variable height table cells with a single pixel line at the top. This is the drawing code that I'm using, but it doesn't work. Below is the code for the header: // In OneLine.h @interface OneLine : UIView {} @end And the drawing code: // In OneLine.m - (void)drawRect:(CGRect)rect { // Drawing code...