objective-c

function example for sortedArrayUsingFunction in Cocoa

I'm trying to create a compare function like the example on the apple site: http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Classes/NSArray%5FClass/NSArray.html#//apple%5Fref/occ/instm/NSArray/sortedArrayUsingFunction%3Acontext%3A The example is not objective-c. Does anyone know how I can convert the ex...

My code either leaks and works, or doesn't leak and crashes. This doesn't seem like an autorelease problem...

After I finished coding the difficult parts of my game, I found some memory management bugs. objects is a NSMutableArray holding a custom class. - (void) spawnObjects { for (int index = 0; index < INITIAL_OBJECTS; index++) { [objects addObject:[[[MatchObject alloc] initWithImageNameID:(index % 3)] autorelease]]; ...

Display UIAlertView before launching UIImagePickerController

My app asks the user via a UIActionSheet where they want to import an image from (Photo Library or Camera) and then launches the appropriate UIImagePickerController. If the user selects Camera I want to first display a UIAlertView with a camera instructions image relevant to the app. This works, however the UIImagePickerController is la...

Adding string objects to NSMutableArray?

I have a little foundation tool test (Objective-C) that I am playing with and I have a few questions ... #import <Foundation/Foundation.h> int main (int argc, const char * argv[]) { NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; int planetLoop; NSString *tempString; NSMutableArray *planetArray = [[NSMutab...

How to jump to a specific view?

I have 3 views (xib'd) the third view opens a modal view (also xib'd). My goal is to dispose the modal view and jump on the view #1. I used the following code but it does nothing. self.statusView = [[StatusViewController alloc] initWithNibName:@"StatusViewController" bundle:nil]; [self.navigationController popToViewController:self.stat...

iPhone development: pointer being freed was not allocated

Hello, i got this message from the debugger: Pixture(1257,0xa0610500) malloc: *** error for object 0x21a8000: pointer being freed was not allocated *** set a breakpoint in malloc_error_break to debug so i did a bit of tracing and got: (gdb) shell malloc_history 1257 0x21a8000 ALLOC 0x2196a00-0x21a89ff [size=73728]: thread_a0...

What's the missing step/information in this iPhone Interface Builder tutorial?

I'm following a tutorial on how to use Interface Builder from Chapter 2 of Zdziarsky's "iPhone SDK Application Development." The idea appears to be to create a very basic app which consists of a Tab Bar Controller which has two buttons, each tied to a different view object (and each view object in its own respective .xib file). What I en...

how to open camera from native applicatioon in iphone?

i want to write a app in which i open the camera.take a picture and then edit the picture..means put some cool effects on it...something like image editing...does some one knows a good or i say best approach to achieve this? i want to know that is open-gl necessary to create an aap like image editing? i have iPhone with OS 2.0. i also h...

Browser Plug-ins Not Loading in WebView Implementation

I have a Cocoa app that I'm trying to write which displays a webpage. This webpage has an embedded quartz composition in the background that plays and works when in Safari, but it does show in my Cocoa application (it just shows the missing plugin icon in the background instead). The weird thing is that it works on another computer that...

Have been cursing over data packets for 36 hours now, please help!!

Ok Here is the problem. I am trying to send through a structure or anything through the apple bluetooth send network packet code. The code to send is below -(void)sendMessagePacket:(GKSession *)session packetID:(int)packetID withData:(void *)data ofLength:(int)length reliable:(BOOL)howtosend { static unsigned char networkPacket[maxPack...

How to Get time difference in iPhone.

I have 2 arrays with time values in it. They are in the following format. mm:ss:hundreds of a sec. I want to get the difference between the two [lastObjects] in the arrays. NSDate is not working because the last value is in hundredsth of a sec. A question. If the second date is larger than the first will it give me a negative numb...

seeing if an object exists at index[i] in NSMUtableArray

People I'd like to see if an element at index[i] is not present in a different (or current ) array. So for instance if my array looked somewhat like this [wer, wer4 , wer5 , werp , klo ... Then I would like to see if aExerciseRef.IDE ( which is "sdf" for instance ) does or does not exist at index[i]. I assume I'd have to use some sor...

"Expected expression before '{' token"

I may be missing something silly. But I've been staring at it for a day now and re-working it and what not. I still get the same "Expected expression before '{' token" error. Before I got this error I was having trouble getting my button to do what I was asking it to do, which was simply add the two numbers and display the answer, basic...

How to draw a dotted rectangle marquee on iphone?

How to draw rectangle something like this in iphone sdk using core graphics ...

objc_startCollectorThread() implicit declaration warning

I'm trying to work through Apple's CoreData Utility Tutorial. It asks me to create a 'Foundation Tool' project in the 'Command Line Utility' section. In XCode 3.2, I only found a 'Command Line Tool' section with a 'Foundation' type in the 'New Project' wizard. So I created the 'Command Line Tool' 'Foundation' type project, and added t...

iPhone SDK: Creating a big, red UIButton

Using the iPhone SDK, how would I go about creating a red "delete" button similar to the one used when deleting contacts on the iPhone? Screenshot (I'm trying to duplicate the red button at the bottom) Thanks! ...

Retrieving the selected object in an NSOutlineView.

I am looking to retrieve the selected object in an NSOutlineView so I can see if the selected object has any children. How would I do this? ...

iphone dev:NSTableView and NSMutablyArray and File Names have exe_bad access

I have a navigation controller, the rootviewcontroller is a tableview, which will show all file names, when user click the file, will show the file content in contentviewer. User can go back use navigation bar. The problem is sometimes user use navigation bar go back. The app crashed. say exe-bad-access at cellForRowatIndex this line: ...

libxml/tree.h no such file or directory

i am getting following errors. I have already added libxml2.dylib to my project, how ever i am getting this type of trouble. Plz any body help me. ...

Getting CPU time in OS X

I have an objective-c application for OS X that compares two sqlite DB's and produces a diff in json format. The db are quite large (10,000 items with many fields). Sometimes this applications runs in about 55 sec(using 95% of the cpu). Sometimes it takes around 8 min (using 12% of the cpu). This is with the same DB's. When it is only us...