cocoa

Different encoding results when using writeToFile:atomically:encoding:error: vs. createFileAtPath:contents:attributes:

Hi there, In my iPhone App I have the capability to export data to an .txt file and send it via Mail – but have currently problems regarding the encoding. To attach the file to mail I simply create a NSData instance from a NSString instance as followed: NSData *dataToExport = [[NSData alloc] initWithData:[myExportString dataUsingEncod...

Should I release this NSString?

Guys: Please help. I have a utility class to return a NSString with encoding. Like this: /*Get a NSString with chinese encoding*/ +(NSString*) getGBKString:(void *)buffer { NSString* string = [[[NSString alloc] initWithBytes:buffer length:sizeof(buffer) encodin...

Sending messages to a thread?

I need to imlement in cocoa, a design that relies on multiple threads. I started at the CoreFoundation level - I created a CFMessagePort and attached it to the CFRunLoop, but it was very inconvenient as (unlike on other platforms) it needs to have a (systemwide) unique name, and CFMessagePortSendRequest does not process callbacks back t...

NSApplication resigning front most application status: hide v. deactivate

Hi, I've got an application that needs to become the front most application after a timer expires and resign the front most status when the timer is started by pressing a button, e.g. click "start timer" -> app resigns front most application timer expires -> app becomes front most application I deliberately paraphrased things a litt...

FLOSS that implements badging and contextual menu in Snow Leopard's Finder

Apparently with Snow Leopard, due to rewrite of Finder in Cocoa and removal of Contextual Menu Plugins, it is no longer trivial to do either badging nor contextual menus, however Dropbox seems to both add a contextual menu in the managed folder, and add status badges. Is there an open source project that managed to solve this problem? ...

Cocoa app interface randomly "disconnecting" from program code

I have a multi-threaded Cocoa app that processes images. The program has a progress bar and some text showing how far along the process is. This all works great. However, sometimes the interface will just freeze up and everything will stop updating. The progress bar stops moving, and the text stops updating in the percentage counter. How...

Objective-C bindings for YAJL: How to put boolean values in JSON dictionary?

I use Objective-C bindings for YAJL in my Mac OS X application. I could not find out how to insert a boolean value (to appear as key:true in the JSON string) in my NSDictionary: NSMutableDictionary* jsonDict = [NSMutableDictionary dictionary]; [jsonDict setValue: YES forKey: @"key"]; The code above does not run (obviously because YE...

PlainOAuth 401 Error

I'm making an iPhone program that can post to Twitter. I've downloaded Januus' PlainOAuth project, and I'm incorporating code into my own project. PlainOAuth is working fine, but my own project generates the following in the console when I post: 2010-10-18 21:53:09.990 TwitterTableView[18860:207] Status posted. HTTP result code: 401 O...

Obj-C: Constantly observe changes to a property(double value) to trigger if's

I want to use the property currentPlaybackTime, which returns a double value to trigger a series of if statements at certain points throughout the movie's playback to pause it. Because of the approximate behavior of doubles, it never syncs up with the value in my if statement, and the movie doesn't stop. I can't use a range though becaus...

Change NSTableView alternate row colors

I'm using the "Alternating Rows" option in Interface Builder to get alternating row colors on an NSTableView. Is there any way to change the colors of the alternating rows? ...

NSOutlineView getting an assertion error when expanding items

Looks like my data model has some problem, so that i get this error from time to time when expanding items. Does anyone has an idea what this assert means? 2010-10-20 03:04:47.547 test_tree[60332:613] * Assertion failure in -NSOutlineView _expandItemEntry:expandChildren:startLevel:, /SourceCache/AppKit/AppKit-949.54/TableView.subproj/NS...

Help please with CGBitmapContext and 16 bit images

I'd LOVE to know what I'm doing wrong here. I'm a bit of a newbie with CGImageRefs so any advice would help. I'm trying to create a bitmap image that has as it's pixel values a weighted sum of the pixels from another bitmap, and both bitmaps are 16bits per channel. For some reason I had no trouble getting this to work with 8bit images b...

Add missing objects to create an ordered collection

Hi folks, The subject is vague because I'm not sure how to articulate in one sentence what I want. Here goes: I have an NSArray of NSDictionaries. Each NSDictionary represents one day of the calendar year. Each NSDictionary has a key "date" with a value of NSDate. There should be 365 NSDictionary items in the array. The dictiona...

What is the most efficient way to count number of word in NSString without using regex?

I am a bit new to Objective C and was wondering if there is a better way to count words in a string. ie: NSString *str = @"this is a string"; // return should be 4 words .. The way I now how to do it is by breaking the string into an array of words space (' ') character and count the array. Any advise will be appreciated! Thanks!!...

NSString is not appearing properly

I have the following NSString: NSString* searchURL = [NSString stringWithFormat:@"http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.quotes%20where%20symbol%20in%20(%22%@%22)%0A%09%09&format=json&env=http%3A%2F%2Fdatatables.org%2Falltables.env&callback=",symbol]; NSLog(@"URL IS: %@", searchURL...

NSToolbar on bottom of window

How do i put an NSToolbar on the bottom of a window. I need to modify a program that has a toolbar on the top of the window and that needs to go on the bottom now. ...

How to update NSTableView without using -reloadData?

I am new to the Mac. I am trying to update a particular cell in NSTableView without using -reloadData, as -reloadData updates the whole table. I have tried everything but all was in vain. I am trying to do something similar to what we used to do in CListCtrl in MFC or in .NET. ...

How to test with NSUserDefaults?

Hello! In most of my classes that work with defaults I make the defaults object settable: @property(retain) NSUserDefaults *defaults; This is supposed to make testing easier: // In a nearby test class: - (void) setUp { [super setUp]; NSUserDefaults *isolatedDefaults = [[NSUserDefaults alloc] init]; [someObjectBeingTested ...

Mac OS X copy file with progress bar to a webdav share

Hello Stack Overflow, How does one copy the file to a webdav share? We are currently using FSCopyObjectAsync to copy files to local file system or SMB, however it quits almost immediately when copying to a mounted WebDav share. To verify the behaviour I've run rsync and the transfer was completed in about 1-2 seconds reporting the progr...

Showing Password Prompt Only Once - How to?

Hi, I'm building an Cocoa application that modifies a file on the user's operating system which requires admin permission. I have a proof of concept working which uses authopen but it doesn't deliver the UX experience I am hoping to achieve. Every time the file is modified it prompts the user to enter their password. Is there a way to h...