objective-c

Cocoa Virtual Keystrokes Pain

I'm writing an application to respond on a hotkey by copying highlighted text into NSPasteboard's generalPasteboard. After looking around here for a solution for sending virtual keystrokes, I found this: http://stackoverflow.com/questions/1505933/how-to-send-a-cmd-c-keystroke-to-the-active-application-in-objective-c-or-tell I tried the ...

How to convert code to properly release memory

I've taken over a code base that has subtle flaws - audio player goes mute, unlogged crashes, odd behavior, etc. I found a way to provoke one instance of the problem and tracked it to this code snippet: - (void)playNextArrayObject { NSURL *soundURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:[[soundsToPlay object...

How to sort list of object.name in alphabetical order using custom compare in objective-C?

Hi Guys, I am not getting the idea to sort names from each object in the list , please help me. for(int i=0;i<[artistsList count];i++) { Search *obj=[artistsList objectAtIndex:i]; // It is not correct way,I am just explaining the problem [artistsList sortUsingSelector:@selector(myCustomCompare:obj.name)]; } I need custom method to sor...

unarchiveObjectWithFile retain / autorelease needed?

Just a quick memory management question if I may ... Is the code below ok, or should I be doing a retain and autorelease, I get the feeling I should. But as per the rules unarchiveObjectWithFile does not contain new, copy or alloc. -(NSMutableArray *)loadGame { if([[NSFileManager defaultManager] fileExistsAtPath:[self pathForFile:@"...

Add UIView Above All Other Views, Including StatusBar

I'm wanting to create a view (UIControl) which blocks all input and shows a UIActivityIndicatorView while authenticating a user. The UIActionSheet and UIAlertView both manage to add a black semi-transparent view over the top of all other views to block input and I'd like to do similar. I've tried adding my view to the top UIWindow in t...

Update table columns bound to NSArrayController

Hi, I'm fairly new to the world of bindings in cocoa, and I'm having some troubles (perhaps/probably due to a misunderstanding). I have a singleton that contains an NSMutableArray called plugins, containing objects of class Plugin. It has a method called loadPlugins which adds objects to the plugins array. This may be called at any poi...

Generate syntax-colored, hyperlinked source code from Haskell or Objective-C

Are there any packages that can take a directory full of source code (Objective-C and Haskell are the ones that interest me) and generate syntax-colored HTML from it where function names are links to their source code? ...

How to round CGFloat

I made this method + (CGFloat) round: (CGFloat)f { int a = f; CGFloat b = a; return b; } It works as expected but it only rounds down. And if it's a negative number it still rounds down. This was just a quick method I made, it isn't very important that it rounds correctly, I just made it to round the camera's x and y valu...

Passing a column name instead of index in sqlite3

The problem code: NSString *query = @"SELECT Name FROM Category"; sqlite3_stmt *statement; if (sqlite3_prepare_v2(database, [query UTF8String], -1, &statement, nil) == SQLITE_OK) { while (sqlite3_step(statement) == SQLITE_ROW) { char *row =(char *)sqlite3_column_text(statement,0); char *rowData = (char *)sqli...

IS MFMailComposeViewController working on ipod 3.0 ?

IS MFMailComposeViewController working on ipod 3.0 ? ...

Playing wav files with AudioServices in iPhone

Hi All, I am trying to play two .wav files in my appllication, but i am only able to play the first wav file , the second file is not at all playing. I have added the AudioToolbox framework. In my .h file i have included the Audiotoolbox.h file and has the following declarations //Beep Sound SystemSoundID soundFileObject; SystemSou...

Objective C - displaying data in UITextView

Hi, I'm having difficulties displaying data in a UITextView in iPhone programming. I'm analyzing incoming audio data (from the microphone). In order to do that, I create an object "analyzer" from my SignalAnalyzer class which performs analysis of the incoming data. What I would like to do is to display each new incoming data in a TextV...

How to get HDD volume id programmatically?

Hi, everybody. I`m programming in obj-c using cocoa, and I would like to discover the HDD volume id programmatically.I know that I will probably need to do this in pure C and than use it in my app, but even in the C language I could not find any answers. Please help.Thanks! ...

iPhone Core Data - Access deep attributes with to many relationships

Hi everyone, Let say I have an entity user which has a one to many relationship with the entity menu which has a one to many relationship with the entity meal which has a many to one relationship with the entity recipe which has a one to many relationship with the entity element. What I would like to do is to select the elements which be...

How to include other controls in a scrollbar?

I want to create a scrollview with a zooming control and a button next to the scrollbar. Sort of like the "tile window" button in XCode (top right corner of the editor), it should be in the same box that usually is used by the scrollbar only. Do you have an idea of how to approach this? I was thinking to use an NSScrollView and set the...

Trouble getting search results using MGTwitterEngine

I'm using a version of Matt Gemmell's MGTwitterEngine, and I'm trying to get some results from the getSearchResultsForQuery method. // do a search [_engine getSearchResultsForQuery:@"#quote"]; // delegate method for handling result - (void)searchResultsReceived:(NSArray *)searchResults forRequest:(NSString *)connectionIdentifier { ...

In OSX, how do I determine the position of windows, and which window is active?

I'm working on an idea for a type of window manager for OSX, similar to Cinch or SizeUp. In order to do this I need to be able to determine the positions of various windows, and which window is active. Some kind of callback when the active window changes would also be useful, as would how to handle multiple screens and multiple spaces....

How to get the size of a NSString

Hi. A "quicky": how can I get the size (width) of a NSString? I'm trying to see if the string width of a string to see if it is bigger than a given width of screen, case in which I have to "crop" it and append it with "...", getting the usual behavior of a UILabel. string.length won't do the trick since AAAAAAAA and iiiiii have the sam...

Sort NSFetchedResultsController results by user location

I have an application that contains some Locations in Core Data, and I want to show them to the user in order of proximity to the user's location. I am using an NSFetchedResultsController to serve the locations to the Table View. I thought about creating a virtual accessor method that returns the location's distance from the user, that w...

error: 'AcceptCallback' undeclared

Hello, I'm trying to create a TCP server for iPhone. I am following an example Journal of the iPhone to help "SimpleNetworkStream". At compile time I get an error "error: 'AcceptCallback' undeclared (first use in this function). Could someone help me understand why all of this. The statement seems identical to that made by the example Jo...