cocoa

Why can't access cocoa control in a pthread?

When I use pthread in cocoa, and want to access cocoa control in pthread function(setBtnState), it doesn't work. What's the problem? The following is the source code: AppController.h 1 // 2 // AppController.h 3 // PThreadTest 4 // 5 // Created by zhu on 10-9-5. 6 // Copyright 2010 __MyCompanyName__. All rights reserved...

Need a solution to convert and store date/time in correct local time compared to device timezone

Hi Ok, I am not sure how to ask this question so that it can be understood... I need to store some schedules on a server (Ruby on Rails) from a iPhone. On the iPhone device the time is relative to the device timezone settings, but on the server I need to store the data in the servers local timezone correctly so that the scheduled event...

Reset Spinning Progress Indicator

A simple question here for many of you. I have an indeterminate NSProgressIndicator which I start and stop many times in my code. Does it reset when you call restart it, or do you have to manually do that? If you do have to do it manually, how would I go about doing it? Many thanks, jrtc27 ...

Rounded NSTextFieldCell like iCal

I'm trying to draw an NSTextFieldCell subclass that looks like the rounded event item normal table in iCal. Based on this question, I've got the following code in my subclass: - (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView { NSGradient *gradient = [[NSGradient alloc] initWithStartingColor:[NSColor lig...

resize a Mac Os X window to just keep the title bar

Hello, I am trying to resize programmatically a window in order to keep just its titlebar. WindowShadeX : http://unsanity.com/haxies/wsx is doing this and I am wondering what can be the solution they are using. Thanks in advance for your help, Regards, ...

Is there a way to get an NSArray of NSRanges for an occurrence of an NSString inside of another NSString?

Hello, I have been recently working on an easy to use Syntax Highlighting system for a personal project. So far, I have everything working properly by finding the range of specific strings and highlighting that range in the NSTextView. Everything works until you try to type a highlighted word twice, which causes the error demonstrated b...

I need to do some advanced text styling of NSTextFieldCell.

First i need some background color on the text only. Like the headers in the F-Script Browser Setting [cell setBackgroundColor: [NSColor blueColor]]; colors the whole cell space not only the text. Also i would need underlined and strikeout text. And to make things readable i would finally like to change the colors (foreground/backgro...

Calling setNeedsDisplay:YES on layer-hosting view does not redraw the view

I have a layer-hosting view set up like this in a custom NSView subclass: [self setLayer:rootLayer]; [self setWantsLayer:YES]; I add all the sublayers to the layer tree after I called setNeedsDisplay on each sublayer. Each layer's content is provided by a drawLayer:inContext method of my layer's delegate. Here is my problem: After i...

Resizing Nested NSViews

In order to categorize a wide variety of unique views, I have an elaborate setup: main categories are selected via a toolbar, and then specific panes are selected in a category's NSScrollView. This looks like: window -> NSViewController controlling five views -> sub-NSViewController for each view controlling X views -> each view contains...

How to define a class that sends an action like NSButton?

In Cocoa, how do you define a class that sends an action? I want to be able to connect the action to the selector of another object in IB in the style of NSButton. I would prefer not to subclass NSControl if possible. ...

EMKeyChain Problems

I want to store the FTP Password in a Keychain rather than in the NSUserDefaults. So I used a wrapper called EMKeyChain to store the problem. The problem being is that it won't load the password when the Preference Window is loaded: Note: FTPPassword is a IBOutlet for NSTextField in PreferenceController.h -(void)windowDidLoad { //Check...

GC on unregistered thread in a Core MIDI callback

Hi, I am just getting started again with Mac development. I am using CoreMIDI which is a C API which allows me to define a C callback function to be called from the MIDI server on a separate thread whenever a MIDI message arrives. The registration of this callback is done in Objective-C/C code triggered by an awakeFromNib call. It see...

The Why and the How of Creating a Watchdog in Cocoa/Objective-C

Happy Monday to you all! Here is my situation. Any assistance greatly appreciated! I have created an executable that when installed gets placed in the Launch Agents folder of the machine. In theory it should run perpetually, collecting data every second. It can stop when the machine is asleep, but restart when the computer is reactivat...

NSScrollView does not contract to fit document view

I have a custom view in an NSScrollView. You could imagine it to be similar to an NSTableView. This document view can reflow its data, so if the scroll view becomes narrower, the document view can grow in height. It all works fine, except that if the scrollview widens, making the document view shorter in height, the scrollers do not upd...

Sqlite3_step() keeps returning SQLITE_MISUSE on this query. Any pointers?

I am trying to open a sqlite db in the viewDidLoad routine and trying to send a sql query through to the db, but the sqlite_step() fails every time. I am not sure what's wrong here. I am just trying this as a hello world attempt at sqlite3. #import "RootViewController.h" #import "sqlite3.h" static sqlite3_stmt *statement = nil; @imple...

Why does a Daemon randomly stop?

Hello, This is sort of related to a previous, yet so far unsuccessful question of mine. I have a daemon that is placed in the LaunchAgents folder (on Mac) and it should run perpetually in the background, but after a couple of days it just stops for no apparent reason. I have no idea why and thus my question: What are the reasons that a...

SecurityKit problem, snow leopard

Hi, Very simple question but I can't seem to get it to work. Imagine the following code, why would the compiler give me the errors below? I've imported the relevant header file, included the framework. Target is 10.6. #import <Security/Security.h> - (void) snowLeopardCodeSignCheck { SecStaticCodeRef ref = NULL; } 'SecStatic...

NSButton Mousedown event

Hi, I'm trying to show a pop up menu on mouse down on a button. The button should appear pressed while mouse down, and be "un pressed" on mouse up regardless of any of the menu item been selected. Similar to the Expose/Space Preference panel "+" button for adding application. So far I tried 3 methods: Sent action when button is clic...

NSEntityMigrationPolicy subclass methods not being called

I am trying to migrate from one .xcdatamodel file to another. I have a NSEntityMigrationPolicy subclass, the name of which I have entered in xcode-> .xcmappingmodel file -> entity -> "custom Policy" field. I run my app which successfully opens and runs the previous version of my data so I can only assume basic migration has worked. HOWE...

Objective C Project using C++ POSIX Classes

Hi, I have to create a iOS Programm using Code of some C++ POSIX Classes. I already read the "Using C++ With Objective-C" manual of the Apple Developer Center. They describe how to mix C++ & Objective C code in a .mm file. My question is, is there any possibility to use the C++ Classes in my .h/.m files of a normal Objective C Project?...