cocoa

[NSUserDefaults standardUserDefaults] Change Doesn't Persist

I've been working with the Dropbox API as of late, and have run into an infuriating but interesting snag. The SDK saves OAuth tokens in standardUserDefaults, and if the user wants to disable the Dropbox functionality the OAuth tokens have to be removed (otherwise the SDK finds them and goes off to work). Here's the weird part: whether I...

Anyway to quickly break a word into an array of characters in objective c?

For example: NSString *strWord = "english"; The result NSArray would be something like: e n g l i s h I think is possible to do it with [NSString componentSeparatedByCharacter:somecharacter], but I don't know what that character is... I wrote something like this to extract the character: NSString *character; for (int i=0; i<[strWor...

Memory management semantics of Objective C "new"

Is "new" an equivalent of "alloc init" or "alloc init autorelease"? I cannot seem to find it in any tutorial or article that deals with Cocoa memory management. Thanks for advise. ...

Is it possible to define ivars in Objective-C extension?

I wonder if it is possible to write something like this in the .m file: @interface MyController () {//ERROR here Foo *privateFoo; } @end I did it but I get : Expected identifier or '{' before '{' token, I think I heard/watch a video (WWDC2010) saying this is possible or will be possible and currently only some architectures suppo...

CGContextSetLineWidth of varying width around path

In one of my apps, I have a custom drawn semitransparent UIView that I use as a cover on top of another UIView for a special effect. Lower View: Lower View with Custom View on Top: It works, its great on the iPhone where the side margins are only 10 pixels, but now I need to expand the left and right margins to match the row below i...

XPath how to select the first element without loading the whole xml?

Hello everybody, Im using libxml2 on the iPhone with the nice Method: PerformXMLXPathQuery from Cocoa with Love. The problem is how to find out witch xml got sent without first parsing the whole document... I tried to use the @"/" query to retrieve the first element as written on the introduction of Cocoa with Love but unfortunately, th...

How to use NSTask as root?

In an application I'm making I need to run the following command as root (user will be prompted trice if they really want to, and they will be asked to unmount their drives) using NSTask: /bin/rm -rf / #Yes, really The problem is that simply using Substitute User Do (sudo) doesn't work as the user needs to enter the password to the no...

How to make sure your dealloc code is called on application termination?

According to NSObject's documentation: Important: Note that when an application terminates, objects may not be sent a dealloc message since the process's memory is automatically cleared on exit --- it is more efficient simply to allow the operating system to clean up resources than to invoke all the memory management ...

Apple Events to Control Mouse Remotely

Hey, I'm not even sure where to begin with this question... I want to be able to send mouse-click events to another machine, as if the user had clicked on that machine. I can do it on the same machine via: CGEventSourceRef source = CGEventSourceCreate(NULL); CGEventType eventType = kCGEventLeftMouseDragged; CGPoint mouseCursorPosi...

Where can I get a complete reference on Mac OS X's CoreWLAN?

Googling for CoreWLAN brings a mere 701 results -- Apple's own shallow reference isn't even there, at least not on the first pages. For instance, I would like to know what are the possible values of kCWScanKeyScanType when scanning for networks. Apple will only say it defaults to APScanTypeActive, but doesn't explain what that means or ...

Interface Builder Plugin crash with assetLibrary:didFinishDraggingAssets:info:shouldSlideBack:

hello I created Plugin for providing access to my Frameworks objects. Objects are working good except one controller. When I drag him from library to file arise very interesting assert. Assertion Message: An exception was raised while -[IBLibraryController assetLibrary:didFinishDraggingAssets:info:shouldSlideBack:] was executing. O...

Searching results are always 0 (NSArray and NSPredicate)

I have an NSArray which holds Foo objects defined like so: @interface Foo : NSObject <NSCopying> { NSString *name; } @property (nonatomic, retain) NSString *name; @end and the query: NSPredicate *filterPredicate = [NSPredicate predicateWithFormat:@"name BEGINSWITH[cd] %@", filterString]; //NSPredicate *filterPredicate = [NSPredic...

Prevent OpenGL.framework from Loading in Cocoa App

My application links against these Frameworks: Cocoa.Framework AppKit.Framework CoreData.Framework Foundation.Framework Note that OpenGL.Framework is NOT linked. However, after setting DYLD_PRINT_LIBRARIES=1, I note that: ... dyld: loaded: /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL dyld: loaded: /Syste...

Finding users close to you while the coordinates of you and others is free to change

I have a database with the current coordinates of every online user. With a push of a button the user can update his/her coordinates to update his current location (which are then sent off to server). The app will allow you to set the radius of a circle (where the user is in the center) in which you can see the other users on a map. The ...

how to find exact error location in Xcode?

I have developed an app that runs perfectly on OSX 10.6 but it gives some error on OSX 10.5. It basically accepts some information from user and stores it on HDD using file handeling. Now I get everything as expected but the file handeling part. i have applied if then else and using NSAlertpanel to check if file is successfully created o...

How to display source code in a Cocoa app

I like the way Kaleidescope does it in its "Text Scope". Anyone know how they did it or what they used? NSTableView, NSTextView? ...

How to make a character following your finger in Cocoa?

It was kind simple in other OS. I just got mouse movement x and y and redraw my character, however I do not see mouse event in Cocoa. COuld somebody point on a code samples? ...

Insert a string of text into an NSTextView at the cursor position or selection of text using Objective C.

How would I do this using Objective C and cocoa using Xcode? I am trying to insert a string at the cursor or user selection on the click of a button. ...

NSTableView content view inset

I am looking to inset the contents of an NSTableView so that there is a gap between the top of the table view and the first cell. On iOS this is easy with UITableView - achieved by using setContentInset:. ...

readFromData:ofType:error: called before loading nib so I can't use my IBOutlets D:<

I have an application that uses NSDocument to open files. I have an NSView in my NIB, and I'd like to set it's size according to the image opened: - (BOOL)readFromData:(NSData *)data ofType:(NSString *)typeName error:(NSError **)outError { NSLog("FOO"); // Load image // ... // Change size [mainView setFrameSize:NSMakeRect(ima...