cocoa

how to use sortUsingFunction:context

appdata.items is NSMutableArray. I connot compile This code. Error code is "prop.173 has an incomplete type". NSInteger compareInfo(id aInfo1, id aInfo2, void *context){ NSDate* info1 = [aInfo1 objectAtIndex:2]; NSDate* info2 = [aInfo2 objectAtIndex:2]; return [info1 compare:info2]; } -(void)saveData{ NSData* data = [[NSMutab...

Transparent layer-backed views

I'm trying to perform some simple animations using CA layers on transparent window and corresponding view. The problem I have is that every time I turn on the layer backing (either through wantsLayer in code, or with IB) the view stops being transparent. I've tried setting layer's backgroundColor to something with low alpha and I took f...

3 notifications instead of one

I'm developing simple MVC app in Cocoa/Objective-C. I have a strange issue (or misunderstanding) with notifications and KVO. I have AppController object in MainMenu.xib, hence I implement awakeFromNib method where I register for NSImageView changing its image property. I add self as an observer in the following way: // options:3 equals...

Any differences between the way Bézier curves are interpreted by Cocoa and SVG?

I'm definetely new to any kind of graphics (maybe except taking photos :)) so please forgive if my explanation of problem I faced last night is not very precise and understable. I'm trying to generate code in Cocoa which would draw vectors on the base of SVG files. I've translated SVG commands into calls of NSBezierPath methods but rece...

How to Safely Force Shutdown of Mac

What I want I'm developing a little app to force me to only work at certain times of day - I need something to force me to stop working in the evenings so I can be more effective in the day. The option within OS X to shut down my machine at a certain time is too easy to cancel. And you can always log back in afterwards. I want my app ...

NSPredicate with child objects date range query?

I am trying to filter my table with only relevant records by date range. NSPredicate *currentDaypredicate = [NSPredicate predicateWithFormat: @"account.entries.dateCreated > %@ AND account.entries.dateCreated < %@ ", yesterday, tomorrow]; [accountArrayController setFilterPredicate:currentDaypredicate]; But of course this i...

how do I get class info at runtime in objective c

I am pretty new to objective C, I was trying this: I have NSMutableArray with different objects in it of different classes. Now I want to get the class name & related stuff & also check if the respective object is NSString or not. How should I go about it.. I was trying something like this it wasn't working ofcourse for(NSString *str...

Deactivate agent app after launch in Cocoa

What method should be called to deactivate an app right after it's launch in applicationDidFinishLaunching: delegate method has been called? Or maybe there is a better place to do that? The documentation for deactivate method for NSApplication says that I shouldn't call this method directly since AppKit knows better how to deactivate stu...

How to control the text color of an NSTextField when it is displaying a placeholder marker?

When the NSTextField (Label) is bound to a controller selection with bindings, and I have specified placeholder values for the Multiple Values Marker, No Selection Marker, etc it draws the text with a gray color that does not show up well on a dark background. Is there a way to change the text color it uses to display the placeholder te...

Talking head library for Mac OS X

Is there a "talking head" library for Mac OS X / Cocoa / Objective-C? Specifically the ones that simplify translating spoken text into visemes / facial expressions? Microsoft has "Microsoft Agent" as part of their Text to Speech API, does the Mac has a worthy competitor for this feature? ...

Populating NSImage with data from an asynchronous NSURLConnection

I have hit the proverbial wall trying to figure out how to populate an NSImage with data returned from an asynchronous NSURLConnection in my desktop app (NOT an iPhone application!!). Here is the situation. I have a table that is using custom cells. In each custom cell is an NSImage which is being pulled from a web server. In order to ...

UIImageView - How to get the file name of the image assigned?

Is it possible to read the name of an UIImageView's image that's presently stored in the ImageView? I was hoping you could do something kind of like this, but haven't figured it out. NSString *currentImageName = [MyIImageView getFileName]; ...

How i can track Safari activity from my application

I have to develop an application to monitor Safari activity like all open url , tabs on particular window and loding time of particular url. I also need to track online streaming that is happening on particular opened htmm page URL of streaming source, which player is being used for streaming and all other basic information which open...

How to bring NSWindow to front and to the current Space ?

I'm using this code to bring up my window: [self.window makeKeyAndOrderFront:self]; [self.window setOrderedIndex:0]; But often it will be beneath other windows or displayed in other Space desktop that I last open it in. How do I make it always appear "in front" to the user? Update I found the answer from previously asked question; ma...

Object instance memory management.

This is a follow on from another question, my question is regarding the use of the retain/release in main(). From my understanding in this simple example the retain/release statements are not needed. BUT in more complex situations its best practice to add them as it ensures that the planet instance is not released unexpectedly. +(Planet...

Best cocoa data structure for list of files

I'm writing a program that processes hundreds of files when run. Right now each file and folder is stored in an object I created (it contains the filepath, filetype, filesize, a pointer to an offset in the file, and if it is a directory), and those objects are placed in a NSMutableArray. A big problem with this is at the end of process...

Use ZIP-archives to store NSDocument data

I noticed that Apple started using zip archives to replace document packages (folders appearing as a single file in Finder) in the iWork applications. I'm considering doing the same as I keep getting support emails related to my document packages getting corrupted when copying them to a windows fileserver. My questions is what would be ...

Class Method Instance Scope?

My question is regarding the scope of the object created in +planet. I have been told that "autoreleased objects will stay around for the duration of the method/function they were created in" In my example I am assuming that the scope for the planet instance is within main() and not within the method where I do the initial alloc/init? +...

How to subclass AtlasSpriteManager in Cocos2d?

I need to create some compound sprites that will all move and rotate together. Since it's possible to change the position and rotation of an AtlasSpriteManager I've been trying to subclass so I can create a bunch of shortcuts like CompoundSprite *cSprite = [CompoundSprite spriteManagerWithFile:@"sprites.png"]; [cSprite makeComplexSprite...

CGWindowID from AXUIElement

I'm trying to automate a foreign OSX application using the accessibility API. Some of the state of the application isn't available through the API, so I acquire it through screen scraping. To do this, I need to get CGWindowID for an accessibility object with a 'Window Role'. Is there any direct way of acquiring CGWindowID of a 'Window R...