cocoa

How to detect BPM of the song by programming

In my application, i have to detect all the songs and BPM of those songs. Detect the songs are finished now I have to detect BPM of songs. Does anyone tell me that how can I detect BPM of each song by programming in Cocoa. Thanks, Haresh. ...

How can I access variables from another class?

There is probably a very simple solution for this but I can't get it working. I have got multiple classes in my Cocoa file. In one of the classes class1 I create a variable that I need to use in another class class2 as well. Is there a simple way to import this variable in class2? ...

Mac OSX/iPhone error handling in the App Delegate?

Hi all, I'm curious, how do most of you folks handle errors such as HTTP Forbidden or 5xx type requests from a server? Or say an exception is thrown in one of your UIViewControllers? Do you typically bubble up the error to the App Delegate and handle generic "window" level errors at that point? Do you couple errors directly into the UIV...

How do I use NSDateFormatter to format an NSString?

I need to be able to format an existing NSString into a different date format. NSDateFormatter has dateFromString and stringFromDate methods, but no stringFromString. Is it possible to take a date that I have in the form of an NSString and reformat it using something similar to: NSDateFormatter *dateFormatter = [[NSDateFormatter all...

I need to return a string in cocoa after http request and xml delegates are complete??

I have the following delegate method of NSURLConnection - (void)connectionDidFinishLoading:(NSURLConnection *)connection { NSLog(@"DONE, Receive bytes: %d", [webData length]); NSString *theXML = [[NSString alloc]initWithBytes:[webData mutableBytes] length:[webData length] encoding:NSUTF8StringEncoding]; //NSLog(theXML); [theXML ...

Passing NSMutableArray to other classes

I have created an NSMutableArray in the implementation of my class loginController. The mutable array contains a set of strings. I want to pass the mutable array with its objects to other classes within my cocoa-project. What is the best way to pass the array? ...

Unable to access property of NSArray in cocoa

I'm trying to pass an NSArray containing strings for use in another class than the one in which it is generated. Therefore I have made it a property as following: loginController.h #import <Cocoa/Cocoa.h> @interface loginController : NSObject { NSArray *myArray; } @property (nonatomic, retain) NSArray * myArray; @end log...

pixel size od NSBitmapImageRep

What is the best way to get the size (width and height) of an NSBitmapImageRep? This is what I'm doing now: NSBitmapImageRep *bitmap; NSInteger samplesPerPixel = [bitmap samplesPerPixel]; NSInteger bytesPerPlane = [bitmap bytesPerPlane]; NSInteger bytesPerRow = [bitmap bytesPerRow]; NSInteger numberOfPlanes = [bitmap numberOfPlanes]; ...

NSNumberFormatter to format US Telephone Numbers

I'm trying to convert a string of numbers, entered by the user, into a sexy string like Phone.app on the iPhone. Here is the code I'm using, which doesn't work (no special format comes out) and after a certain number of digits it just starts adding "0" to the end of the string. NSNumberFormatter *formatter = [[NSNumberFormatter alloc] i...

PyObjC + Python 3.0 Questions

By default, a Cocoa-Python application uses the default Python runtime which is version 2.5. How can I configure my Xcode project so that it would use the newer Python 3.0 runtime? I tried replacing the Python.framework included in the project with the newer version but it did not work. And another thing, are PyObjc modules compatible w...

How do I detect if an application is document-based?

I'm developing a Cocoa/Objective C application that reads the active document from any application using AppScript. I've done this part successfully, but it would be really good to be able to tell for sure whether the application is document-based or not. The obvious approach is to look at the AXDocument attribute of the active window w...

Can anyone provide a working example of AudioFileStreamSeek for the iPhone?

I find Apple's documentation quite limited on AudioFileStreamSeek and I cannot find any examples of actual usage anywhere. I have a working streaming audio player, but I just can't seem to get AudioFileStreamSeek to work as advertised... Any help tips or a little example would be greatly appreciated! ...

Why do NSString and NSLog appear to handle %C and %lc (and %S and %ls) differently?

Apple's String Format Specifiers document claims, The format specifiers supported by the NSString formatting methods and CFString formatting functions follow the IEEE printf specification; … You can also use these format specifiers with the NSLog function. But, while the printf specification defines %C as an equivalent for %lc and ...

Is this a valid use of an Objective-C pointer?

This is a beginner level question in which I'm curious if this is a valid use of a pointer in a statement such as: NSMutableDictionary *foo = [bar mutableCopy]; I get confused when that is valid versus when I'd need to do the following: NSMutableDictionary *foo = [[NSMutableDictionary alloc] initWithCapacity:0]; foo = [bar mutableCo...

MVC and Java in comparison with more strict MVC languages

I've been told Java is not the greatest pick to follow an MVC architecture. I believe I've seen some Java framework solutions to ease this roadbump. However, I a bit confused on why this is. More specifically, why Java's attempt at MVC is often mocked as a "wannabe" approach. I come from a ObjC background (w/ Cocoa of course) and would l...

(iPhone) selectedRange for a non-editable UITextView (or other methods of click handling?)

Hello all, I'm using an UITextView to hold static content (in Chinese, which means that the characters are all fixed width). I want to let users click on a character in the text and bring up dictionary information for that character. I know all of the issues surrounding the lack of copy and paste and all that, but I'm hoping that there ...

Emacs, Objective-C, and autocomplete

I recently switched to emacs for my code editing, and it mostly works well. However, for Objective-C I find myself missing Xcode's autocomplete feature as I have trouble remembering the long function names such as - (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)windowStyle backing:(NSBackingStoreType)bufferingType d...

NSTextField with "padding" on the right

I am trying to get the "remaining chars notice" to show up within my rounded NSTextField and I got it with two NSTextFields with help of the Interface Builder and it already looks like that: But when I write a little bit more it looks like that: The only thing I could think of is to subclass NSTextField and do something with it so ...

Cocoa binding to a particular item in an array controller

Is it possible using NSArrayController to bind a NSTextField's value to a particular item in the array? In particular, I want to bind to a property on the first item in the array, and show nothing if the array is empty. Using arrangedObjects.command shows just "(" -- presumably it's trying to show a multi-line string with comma-separat...

Wrap NSButton title

Any way to have a NSButton title to wrap when it's width is longer than the button width, instead of getting clipped? I'm trying to have a radio button with a text that can be long and have multiple lines. One way I thought about having it work is to have an NSButton of type NSRadioButton but can't get multiple lines of text to work. ...