cocoa

Thread Safety Of Custom Sequential CGDataProvider

When creating a custom sequential CGDataProvder to render a custom image format you specify the CGDataProviderSequentialCallbacks that should be used. While doing some optimization work to improve the speed of my sequential CGDataProvider I started to wonder about the thread safety of those callbacks. Let's assume I have created a si...

NSMutable array invalid after objectAtIndex

@implementation Level @synthesize doors, rooms; - (id) init { self = [super init]; if (self != nil) { rooms = [[NSMutableArray alloc] init]; doors = [[NSMutableArray alloc] init]; } return self; } - (void)generate{ int room_count = 2; Room *room; for (int i=0; i<room_count; i++) { room = [[Room al...

transparent process creation for cocoa components

I have an application A which may or may not need to spawn an application B and will communicate with it using remote messaging (via NSConnections etc.). While i know how to do this if B is started first, i wonder: What is a clean cocoa-based approach of transparently starting B on demand? (For those familiar with COM, i am effectively...

Cocoa + CopyItemAtPath: toPath: fails when copying a folder from a removable storage to local machine

Hi Guys I am trying to copy a folder from removable storage device to the local machine and i am using the function from NSFileManager class "copyItemAtPath: toPath:". It fails and the error description i get is as follows: Error Domain=NSPOSIXErrorDomain Code=1 UserInfo=0x12f49d90 "Operation could not be completed. Operation not permit...

How to stop NSScrollView from scrolling to top when horizontally resizing contained NSTextView?

I have a NSTextView that I want to display a horizontal scroll bar. Following some leads on the internet, I have most of it working, except that I am having problems with the vertical scroll bar. What I have done is to find the width of the longest line (in pixels with the given font) and then I resize the NSTextContainer and the NSTex...

std::locale breakage on MacOS 10.6 with LANG=en_US.UTF-8

I have a C++ application that I am porting to MacOSX (specifically, 10.6). The app makes heavy use of the C++ standard library and boost. I recently observed some breakage in the app that I'm having difficulty understanding. Basically, the boost filesystem library throws a runtime exception when the program runs. With a bit of debugging...

Defining name strings for NSNotification usage without coupling

I'm going to be using NSNotifications in my app to decouple the code. I want the compiler to help me when using strings as the names of the notifications, ie, if I mistype one, I want the compiler to tell me. Using normal strings for this won't work, because the compiler won't know that if I typed "myNotificaion" that I really meant "m...

Alternative paradigm for Mac OS X development

The current standard way of developing Mac OS X apps is with XCode/Objective-C/Interface Builder using the MVC paradigm. Is there an alternative? I'd like to use Interface Builder (XCode too) however I would rather use a different programming language. I come from .NET programming where you can delegate a click to a certain function, ...

Is there an ORM framework for Cocoa, or a framework that accomplishes a similar goal using a different technique?

I'm developing an application that needs to store lots of records in an organized way. Specifically, I'm writing a personal finance app. As you can imagine, this app will contain records of financial transactions that must be sorted in various ways: by date, by amounts, by recipient, by account, etc. And of course, the app will need to q...

How to get NSAlert sheet to return focus to calling window?

I have an OS X prefpane that calls a NSAlert sheet with: [alert beginSheetModalForWindow:[[self mainView] window] modalDelegate:self didEndSelector:@selector(unsavedChangesAlertDidEnd:returnCode:contextInfo:) contextInfo:nil]; Which shows the alert sheet attached to the System Preferences application fine, but when I click the sheet'...

Importing an SSL cert under the iPhone SDK

My app connects to the Schwab OFX server using NSURLConnection . Unfortunately the server uses a very recent intermediate certificate that is trusted on the Mac desktop but not yet the iPhone. (Try the URL—you'll get a cert error on iPhone.) There's no easy way to tell NSURLConnection to ignore an invalid cert that I know of. Thus I'm t...

which delegate method will be invoked when click the tab of safari?

As we know , When we load frame from webpage of safari, we will invoke the delegate methods of webkit informal protocol(WebFrameLoadDelegate): webView:didStartProvisionalLoadForFrame: webView:didChangeLocationWithinPageForFrame: and When we click or change the tabs of safari,which delegate methods will be invoked? Thank you very much!...

Disadvantage of using NSMutableArray vs NSArray?

I'm using an array to store cached objects loaded from a database in my iPhone app, and was wondering: are there any significant disadvantages to using NSMutableArray that I should know of? edit: I know that NSMutableArray can be modified, but I'm looking for specific reasons (performance, etc..) why one would use NSArray instead. I ass...

Encoding/decoding CGFloat on 32- vs 64-bit

I'm converting an app to work in 64-bit. The Apple docs state that the CGFloat type is a float on 32-bit and a double on 64-bit. If that is so, how do you handle encoding/decoding of the value? For instance, if creating an NSNumber from a CGFloat, should I use the -numberWithFloat: or -numberWithDouble: method of NSNumber? The same ques...

Automatic "force repel" layout in Cocoa

You know that in a lot of Mac/iPhone applications (such as your Finder), when you are dragging a icon around, all other icons will be "repelled away" from your mouse and leave space for the icon you are dragging. I am wondering if that's a built-in Cocoa function (in layout constraints etc?). If not, is there any library, or documents o...

how my cocoa application can track streaming-audio activity

I have to develop a application to log online streaming information like opened player(iTunes,Quicktime),running track, total running time of particular track. ...

How to properly quit application, call exit(0) ?

I'm not sure which is the right way, right now I'm just calling exit(0) when a user clicks on the exit button. ...

in what circumstances will a notification NOT post?

I just dont understand, I have used notifications a trillon times, but today I cant seem to get notifications to send from a particular object. This is in a view controller... - (void)buttonPressed:(UIButton*)sender { NSLog(@"buttonPressed"); [[NSNotificationCenter defaultCenter] postNotificationName:@"test" object:self]; } and this i...

NSURL Encoding in ObjC

Hi , How to do URL encoding in NSURL ? Thanks ...

NSTextView non-editable areas of text?

Hi, I have an NSTextView that contains data for the user to edit, but I want to surround it with a header and footer of non-editable data to give the user an idea of context. I don't think an NSTextView can handle the concept of mixed editable/non-editable data, so I've come up with a few ideas. a) Use text attachments with a custom c...