objective-c

Converting NSData to float?

Initially I thought the code presented below was working, the "inBuffer" seems to be correctly getting 4-bytes of data, also the variable MDD_times is correct. NSData *inBuffer; float MDD_times; // FLOAT_002 inBuffer = [inFile readDataOfLength:sizeof(float)]; [inBuffer getBytes: &MDD_times length:sizeof(float)]; NSLog(@"Time: %f", MDD_...

How provide own Sent Messages in Interface Builder

I cannot find documents about the way, in which Interface Builder determines the Sent Message outlets for the graphical connections between components triggering events and messages of other components. I want to generate components encapsulating Finite State Automata. The input part is simple, just define IBAction messages and you can c...

Custom init method in Objective-C, how to avoid recursion?

I want to create a subclass of UINavigationController which always starts with the same root controller. Nothing special, so (to me) it makes perfect sense to override the init method like this: - (id) init { rootController = [[MyController alloc] init]; if (self = [super initWithRootViewController:rootController]) { // do...

UITableView/UITableViewCell tap event response?

I've been googling around to try to figure out what sort of event handles are called when one row (or cell) in a UITableView is tapped, but haven't been able to figure it out. I'm trying to change the image property of the cell when it's tapped. Thanks. ...

List of all running processes

How can I get a list of the names of all currently running processes? (In C/Objective-C on Mac OS X.) ...

Is there a difference between a so called "Variable" and a so called "Pointer"?

I always wonder if it's correct to say that something like THIS is a "pointer", rather than a "variable": NSString *fooStr = ...; Would you call "fooStr" a "pointer" rather than a "variable"? Or is it okay to say both here? ...

NSLog, NSError, bad access

I was doing a rather ordinary addPersistentStore to an NSPersistentStoreCoordinator, and it generated an &error code. So I went to NSLog it, and got an access error when I did this: NSLog(@"Unresolved error %@, %@", error, [error userInfo]); which seems to be the common idiom. When I reformatted the error statement as follows: ...

CorePlot problems

Hi, I started with core-plot now and came to some problems. I followed the tutorial from this page: http://www.switchonthecode.com/tutorials/using-core-plot-in-an-iphone-application and completed with the instructions from this page: http://code.google.com/p/core-plot/wiki/UsingCorePlotInApplications (such as -all_load). But I still h...

How do I inspect a Class in Objective-C?

Update I fixed up the code to eliminate duplication of overridden methods and track originator of property or method by implementing Mark's suggestion. Haven't tackled property types yet (will probably start with property_getAttributes() when I do). Also stripped out vestigial underscores. Basically I need a way to remind myself what ...

Determine font(s) used in uipasteboard text on the iPhone.

Here is the scenerio: The user copies random text with mixed fonts. How do I determine the font(s) used? When the text is pasted from the UIPasteboard into a textview it correctly shows the mixed fonts, so I believe the information is available. UIPasteboard *pasteboard = [UIPasteboard generalPasteboard]; textView.text = pasteboard.stri...

How do we clear out contents in NSMutatableData

how do were clear an NSMutatableData wihtout using release and then re-alloc/init again to be used again? I was looking at resetBytesInRange to be set at zero but I am unsure of this. Anyone can help? ...

IOBluetoothHostContoller in 10.5

The following code compiles fine when compiling as Mac OSX 10.6 as the active SDK (linked with the 10.5 frameworks, 10.5 set as the base SDK) IOBluetoothHostController *controller = [IOBluetoothHostController defaultController]; However, if I compile it with Mac OSX 10.5 as the active SDK, I get an error message saying that IOBluetoot...

Edit UITableViewCells while being dragged around

I've got a custom UITableViewCell subview that has a button on it which has a background color representing a priority. The user is allowed to drag the cells around in the table, which changes the priority of the object represented by that row. I want to update the color of the button when they're done, so I've implemented this: - (vo...

sqlite3_prepare_v2 character limit?

I have data stored in a sqlite3 database and have several places that I read and write data to and from the database. The problem I am running into is that if the SQL statement gets to be very long the sqlite3_prepare_v2 method returns an error. This code works: NSString *strSQL = @"UPDATE commandList SET displayName=?, type=?, formula...

What is the path for an image in iphone development

I have this snippet of objective c code: UIImage *image = [ [UIImage alloc] initWithContentsOfFile:fileName]; fileName is set to "file1.jpg" When I run the code, however, image is set to nil. I know the file does exist I am guessing it has something to do with the path. What path should I be using? ...

Why doesn't this sample code from Apple work?

I am trying to find the full path for a file called 'file1.jpg' I have verified that it is in the app bundle and yet when I run this code: NSBundle* myBundle = [NSBundle mainBundle]; NSString* path = [myBundle pathForResource:@"file1" ofType:@"jpg"]; 'path' doesn't have the path/file i'm expecting. This is code directly from the ...

Redundant Compiler Warnings

I have found that very often, when calling myMethod asoociated with myObject1 from myObject2, I get the warning that "myObject1 may not respond to -myMethod", but then the program runs just fine anyway. Why doesn't the compiler recognize declared methods at compile time? John Doner ...

Recreating the functionallity of the blue “unread dot” on the iPhone Mail app

I am building an RSS reader with a GUI very similar to the built-in mail app. It uses Core Data to store the information once it is downloaded. When a story is downloaded, it has a blue dot to indicate it is new. Once I go back to the main page after reading a story the dot should be gone. It stays there until I scroll or relaunch the ap...

Adding a number to the dock icon

Here is my code: for (NSManagedObject *object in array) { if ([[object valueForKey:@"DueDate"] isLessThan:[NSDate date]]) { count++; NSLog(@"Looped"); NSString *test = [[NSString alloc] initWithFormat:@"%@", [object valueForKey:@"DueDate"]]; NSLog(@"%@", test); } } NSLog(@"%i", count); NSDockTile *aTitle = [[NSApplication shar...

Buffer cannot be Null Paramter:Buffer

Hi all, I am working on an image upload from iphone to an C# web service. Here is the iPhone code NSString *soapMessage=[NSString stringWithFormat: @"<?xml version=\"1.0\" encoding=\"utf-8\"?>" "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:so...