cocoa

Problems with getting glyph outline with appendBezierPathWithGlyphs

I'm working with Objective-C++. I'm trying to get the path outline of a text using NSBezierPaths appendBezierPathWithGlyphs. The problem is: the output is rather nonsense :( What I've written: String str = Ascii8("test string"); int length = str.getLength(); NSFont* font = [NSFont fontWithDescriptor: [NSFontDescriptor fontDesc...

How do I adjust the scrollers in a newly opened document?

Hey guys, I’m writing a document-based Cocoa application with a custom view that does the whole presentation of the document to the user. I finally got scrolling to work, and it feels great. When I open a previously saved document, though, the scrollers remain blank and useless until I resize the window — even if the document view’s f...

XCode's "Add to Repository" not appearing

I started a new project with XCode and I have set up the subversion repository. For some weird reason, in this project the "Add to repository" menu items are not working, both in the main menu and by right clicking a file. If the file is in the repository I can do all the usual things. Newly added files do not show with a question mark e...

Get OSX version with objective-c

How would I be able to get the OSX version in objective-c? I would like to avoid using shell commands. E.g "10.5" or "10.4" ...

Mac OS X - monitor app launch?

I want to write a simple menubar app for Mac OS X. The user will only want to use that app when Safari is opened. To not clutter the menubar unnecessarily, I want to hide and show the menubar icon depending on whether Safari is open or not. Is there maybe some notification that my app could register for? The only workaround I can imagin...

Use Half of QCView

I feel like this should be a simple issue, but I can't figure it out. I have a QCView in my app. When I display it normally, it looks like this: QCView. But, I only want to see the top half of it, because on the bottom half I want to see what is on the NSView under it. When I try to do this, I get this: QCView Half. How can I get it to ...

How to change NSURL file name.

Maybe this is a noob question, i have an NSURL from savePanel, and i want to save the file with such an identifier name. How to change the filename on NSURL? here's my save method : for (int i=0; i<[rectCropArray count]; i++) { //the code goes on.. CGImageDestinationRef dest = CGImageDestinationCreateWithURL(url, outputTyp...

Layer animation works fine first time, but not on second identical invocation

I have an animation that works perfectly on the first invocation. But if I want to animate the very same layer again, using the same code, it completes immediately and the animationDidStop:(CAAnimation *)theAnimation finished:(BOOL)flag is invoked on the delegate with the flag value NO. Here is the code that adds the animation: imag...

Draggable objects in Cocoa

Hi all, I am completely new to objective c and have an quite ambitious project I want to create. One of the things I'll need to do is have a drawing layer, where I can have a circle in the middle, and be able to drag other circles near it to attach them, and then be able to move them around, changing their position around the initial c...

How to convert data to JPEG format?

NSImage * strImage = [[NSImage alloc]initWithContentsOfFile:ImageFilePath] ; NSData *imageData = [strImage TIFFRepresentation]; now what I required is to convert imagedata into JPEG format. I want to work same as in QImage save() do. for the help how save() works i give you link below http://doc.qt.nokia.com/4.6/qimage.html#save pl...

Communication between a Cocoa and a C# application

I have an OS X server application written in Objective-C. I'd like to write a client in C# which runs on Windows systems. Which is the simplest way to do the communication between the two applications? I'm familiar with NSConnection, and I'd like to use something similar. The application is a very simple auction game. The clients pass...

Get a string representation of Constant or Enum in IOKit, possible?

Hello, Is there a way to get a string representation for the Constants and enums defined in IOKit? I making a forage into IOKit and trying to console log out some parameter which USB devices return. But I'm ending up with lists of numbers. Is there another way to list what these mean? For example in IOHIDKeys.h enum IOHIDElementType ...

What happen when we are writing [Obj autorelease] in Autorelease pool?

What happen when we are writing [Obj autorelease] ? For example: NSAutoreleasePool *pool = [[NSAutoreleasePool alloc]init];<br> NSMutableString *str = [[[NSMutableString alloc]initWithString:@""] autorelease];<br> NSLog(str);<br> [str appendString:@" I"];<br> NSLog(str);<br> [str appendString:@" like"];<br> NSLog(str);<br> [str...

How to avoid "unused variable" compiler warnings with conditionally compiled NSLog replacements?

This comes out of my search for a smart variant of NSLog(). One key feature of BetterLog() is that the NSLog() replacement compiles out to nothing for release and distribution builds. The proposed solution (see eg http://stackoverflow.com/questions/300673/is-it-true-that-one-should-not-use-nslog-on-production-code) is define a preprocess...

EXC_BAD_ACCESS when setting ivars directly (without using accessors) inside -init method, why?

I've spent about 10 hours trying to find this bug that was causing my app to crash, and it was in the last place I looked (well it would have been, but last place I ever expected it to be). Originally I thought I had memory management issues (unbalanced retain/release) because the crash would happen every time I sent -removeAllObjects t...

Trouble sharing textures with OpenGL/Cocoa

I am a bit of an openGL novice and I am trying to get texture sharing to work between two openGL views. I created two NSOpenGL view classes and then in the interface builder I created a window that had one of each openGL view. The first view has code in its prepareOpenGl that sets up the texture and assigns it to a global variable, the...

Audio Encoding: AAC files without the 1/10 second silence at the end of the track

Hi, I'm a little confused with an issue that I keep running into. I'm trying to create some sound loops for continuously playing, seamless background music.. everything's fine as long as I stay in AAC/ WAV/ etc, but as soon as I encode the files in AAC I run into a 1/10 of a second at end of the sound file. I'm on the Mac, so I've trie...

Cocoa animations using CATransition in a single view

I want to use CATransition to provide a fading animation between different states of a view. However, this doesn't seem to work with a single view (all examples I found use CATransition to switch between different views). In contrast, a CABasicAnimation works just fine. My example code shows what I'm doing. I have a custom view (TTVi...

How do I deal with the warning Unknown escape sequence '\040' in cocoa

I have the following Warning popping up in a few of the Applescripts I'm running in a Cocoa application: I have tried everything I can think of to remove the error such as totally rewriting it, copying and pasting from another similar script that doesn't have the warning etc. but I can't get rid of it. Can anyone tell me where I might...

Why can't I use Cocoa classes from my Python script?

Today is the first time I've used Python, so I'm sure this'll be an easy question. I need to convert this Python script from a command line application: webkit2png. The end result will be a URL that returns an image of the webpage passed into it as a querystring param. I've achieved this on Windows with .NET and IE, Gecko and WebKit, bu...