cocoa

Cocoa Bindings: NSObjectController not KVC-compliant for the representedObject property

I've been through a bunch of Core Data examples and the Apple documentation. I'm at a wall after working on this all day. All I want to happen is I type some text into a text field, save the file, open it again and see the text there. I made a very very simple Core Data document-based app to experiment. Here are the particulars: 1) ...

How to parse a file for iphone? Should I use NSScanner?

Hi, So I am new to iphone development, but am trying to learn how to take a file that is CSV and read it and save it using Core Data (I think that is the best way?) so that I can display it in a tableview on the iphone. Below is an example of the type of csv file I am working with; 13,1,1,History,,,,,,1 ,263,1,Smith,Bob,Freshman ,317,...

Data Scraping - Cocoa

I'm really not sure where to start looking on this one. I want my cocoa app to read the text from another application running on my mac. It is a simple text window, with copy-paste functionality. I would love to be able to find the window programmatically and drill down to some 'text' attribute, or maybe intercept each text drawing ca...

NSOperation and NSNotificationCenter on the main thread

I have an NSOperation. When it is finished I fire a NSNotificationCenter to let the program know that the NSoperation is finished and to update the gui. To my understanding listeners to the NSNotification will not run on the main thread because the NSOperation is not on the main thread. How can I make it so that the listeners run on...

How do I download contents into an NSData using a Secure URL?

I'm starting with the following snip to download an image NSError *error = nil; NSString *url = @"https://..."; [NSData dataWithContentsOfURL:[NSURL urlWithString:url] options:nil error:&error]; When this code runs, the error instance contains an error without a whole lot of information in the userInfo. It's just the secure url that ...

NSOperation and the Autorelease pool

I created an NSOperation. Do I also need to create an autorelease pool for this or is it all handled for me like voodoo black magic? ...

Is this the right way to add items to NSCombobox in Cocoa ?

I'm Delphi programmer and very new to Cocoa. at first I tried this : -(void)awakeFromNib { int i; NSString *mystr; for (i=1;i<=24;i++) { [comboHour addItemWithObjectValue:i]; } } But it didn't work. Then I tried to search on Google but no luck. After experimenting about 30 min, I come with this: -(void)awake...

How do I find information on other applications running on the computer on Mac/Cocoa/Obj-C?

I want to find which applications are running, particularly I want to know which one has a window that has focus. So at any given time I want the app to know which application the user is actively working with. I can't figure out how to determine which app is selected, I can only see which window they are using in my app using keyedWindo...

how to create sql database connectivty in cocoa???

Hiii, I am creating a preference Panes (in system preferences).I want to fetch data from sql database.....HOw do i do that??? plz tell the code for basic sql database connectivity in cocoa... ...

Why is this NSTask terminationStatus returning a nil value?

I know the task returns a value to standard error, which I can see by entering "echo $?" in the terminal after running the task manually. Now this code: [aTask launch]; [aTask waitUntilExit]; int status = [aTask terminationStatus]; looks ok, but gdb says status is a location at 0x0 and cannot be accessed. Does anybody know of any bu...

Trying to save document window dimensions through Core Data

Hi there. I am trying to save the dimensions of my document window through Core Data. I have used the following code to save the width and height: managedObjectContext = [[[NSDocumentController sharedDocumentController] currentDocument] managedObjectContext]; NSSize windowSize; windowSize.width = documentWindow.frame.size.width; windo...

Insert UImageVIew into UITextField

How can I add an image to a textfield? I saw it in a few apps, but can't get around it. Also based on the location of the curser, the imageView will be initialized (add image to next line). Thanks. ...

How do I safely move / swap files in Cocoa?

In a cocoa app of mine, there is a method that does some operations on a sqlite database's schema that could be destructive, so first we make a rollback copy of the database, and if there's an error, we call the following method to replace the db file with the rollback file. Note that I definitely want the db file replaced with the rollb...

Is NSPersistentStoreCoordinator Thread Safe?

I'm working on an iPhone app that uses Core Data. The app makes a call to a web service, parses the resulting XML file, and then creates or modifies Core Data objects in my app. I already handle the web service call and parsing asynchronously, but I've been handing the parsed data back to the main thread to manipulate the Core Data objec...

Create pdf using cocoa?

Hi! There is some tutorial about how to create a pdf using cocoa? I can't find anything. I looked for it on the web and it seems that I need Quartz to do it, but there aren't practical examples. Can you help me? Thank you in advance. —Albé ...

Lock screen by api in mac os X

Is there a Api, that can lock the screen as the menu thing you can add from keychain preferences? ...

Making an NSButton resize its image (Cocoa OSX)

I could not find a way in the documentation to tell an NSButton to resize its image to fill up the whole button. Is there a way to do this programatically? ...

Objective-C #define directive demonized for String constants

I've reading in several post and in Apple's code guidelines that in Objective-C String constants should be defined as extern NSString *const MY_CONSTANT; and that the #define directive should be avoided. Why is that? I know that #define is run at precompile time but all string will share the same memory address. The only advantage I read...

How do I render a view which contains Core Animation layers to a bitmap?

I am using an NSView to host several Core Animation CALayer objects. What I want to be able to do is grab a snapshot of the view's current state as a bitmap image. This is relatively simple with a normal NSView using something like this: void ClearBitmapImageRep(NSBitmapImageRep* bitmap) { unsigned char* bitmapData = [bitmap bitmap...

NSOperation and NSOperationQueue callback

I have a class. Inside this class I pass an NSOperation into the NSOperationQueue that lives in my global variables. Now my NSOperation is finished. I just want to know that it is finished in my class and to have the operation pass data to that class. How is this typically done? ...