cocoa

When last row in section of UITableView with Core Data is moved -> NSRangeException

Hi: Moving rows between sections in Core Data backed UITableView works quite fine after I've implemented a 'userDrivenChange' check in 'controllerDidChangeContent:', as mentioned in the apple docs. But only when moving the last row of a section to another section I get a NSRangeException. There is obviously a problem when sections get e...

Maintaining position of content view after window resize?

I created an NSWindow object in IB which contains some textFields and buttons at the top and an NSTextView beneath them. I then reduced the window height so as to hide the textView from sight when the window is initially opened. What I'm trying to do is to resize the window height programatically (thus exposing the textView) if any data ...

Convert hex data string to NSData in Objective C (cocoa)

Hi, fairly new iPhone developer here. Building an app to send RS232 commands to a device expecting them over a TCP/IP socket connection. I've got the comms part down, and can send ASCII commands fine. It's the hex code commands I'm having trouble with. So lets say I have the following hex data to send (in this format): \x1C\x02d\x00\x...

modifying string content of XML file in CDATA block

Hi, How can i modifying the string content in CDATA block of an XML file, such as For reference[(text)] please look below syntax, <![CDATA[<FlowDocument FontFamily="Helvetica" FontSize="24" Foreground="#FFFFFF00" TextAlignment="Left" PagePadding="5,0,5,0" AllowDrop="True" xmlns="http://xyz.com"&gt;&l...

Changing how IKImageBrowserView indicates the drop position

I can make a single row IKImageBrowserView by setting the [imageBrowser setContentResizingMask:NSViewWidthSizable]; but in this case while i drag an image inside image browser to rearrange it, the drop place highlights with horizontal line(vertical line expected). how can this be changed? Many thanks. ...

Error saving NSImage as NSData

Hi there. I am using the following code to save a frame of a movie to my desktop: NSCIImageRep *imageRep = [NSCIImageRep imageRepWithCIImage:[CIImage imageWithCVImageBuffer:imageBuffer]]; NSImage *image = [[[NSImage alloc] initWithSize:[imageRep size]] autorelease]; [image addRepresentation:imageRep]; CVBufferRelease(imageBuffer); NSAr...

Can't update text in UILabel

I have created my ViewController from UIViewController where add UILabel as; @property (nonatomic, retain) UILabel* progressLabel; I initialize this label in loadView - (void)loadView { // Set main view to View Controller UIView* localView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame] ]; self.view = local...

Program structure regarding NSTask

Hi, I want to run an unknown amount (unknown at compile time) of NSTasks and I want to run an unknown amount (again, at compile time, max. 8) of them simultaneously. So basically I loop through a list of files, generate an NSTask, run it until the maximum of simultaneous tasks are ran and whenever one finishes another NSTask starts unti...

Saving System Profiler info in a .spx file using NSTask

In Cocoa, I am trying to implement a button, which when the user clicks on will capture the System profiler report and paste it on the Desktop. Code NSTask *taskDebug; NSPipe *pipeDebug; taskDebug = [[NSTask alloc] init]; [[NSNotificationCenter defaultCenter] addObserver:selfselector:@selector(taskFinished:) name:NSTaskDidTermi...

Core data to-many NSPredicate with AND

I'm trying to write a query for the find-as-you-type search bar. What I want to do is query "Kind", and return any Kinds for which there is a LocalName with ('name' LIKE %@ AND localeIdentifier == %@). If I'm only searching the names (so ignoring the localeIdentifier), I could do something like this: ANY localized.name LIKE %@ What...

Draw an NSView into an NSGraphicsContext?

I have a CGContext, which I can turn into an NSGraphicsContext. I have an NSWindow with a clipRect for the context. I want to put a scrollview into the context and then some other view into the scrollview so I can put an image into it... However, I can't figure out how to attach the scrollview into the context. Eventually the view will...

Problem with fullscreen OpenGL on the Mac

Hi, programmers! Now I am porting some OpenGL tutorials from win/glut to cocoa/mac os x. In the windowed mode everything works, but when context switches to fullscreen, screen may be empty (only clear colour)! For example: in the first, second, third times cube is, but in the fourth time cube is not. Even if app launches in fullscreen w...

Best practices for local constants in objective-c

I see a lot of objective-c code that just #defines local constants it needs, and then proceeds on its merry way. The problem is that, as far as I know, #defines aren't scoped. Many of this is in Apple's own example code. For example, in the TableViewSuite example 5, the drawRect function in TimeZoneView.m contains the following block:...

Directories under a path in Objective-C

I'm using UKKQueue to keep an eye on changes to files in a directory. But sometimes there are more directories below the main one and it will not pick up changes to files made in those folders. Therefore I would like to also register those paths to be watched. I can't however get a folder list easily. I can get a list of EVERYTHING using...

Error searching directory with ODQuery

Hi there. I'm trying to search an LDAP database using the ODQuery method. I have the following code set up: - (void)awakeFromNib { [self startSearch:@"john"]; } - (void)startSearch:(NSString *)searchString { nodeName = @"http://sububria.org.au"; session = [ODSession defaultSession]; searchNode = [[ODNode alloc] init]; searchNode = [OD...

How to link Cocoa static library to C command line target?

I have static library target, which uses Foundation classes(NSArray,etc) . I want to use this static library in Command line tool target. The command line tool contains only C files. From command line tool I want to call a method exported in static library. So I have modified header search path and linked the static library. When I comp...

Asking WebView to load webpage from different class

Hi, I have a WebView that I need to ask to load a website from a different class.Therefore I implemented the following function: -(void)performResearch:(NSString *)aString { NSLog(@"Received Request!"); [[researcher mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:aString]]]; } In my other...

Read SQLite problem

I have NSTableView with two columns, and i wanna fill them entries from SQLite database. this method is make query for table -(void)getPersons { NSString *file = [[NSBundle mainBundle] pathForResource:@"persons" ofType:@"db"]; sqlite3 *database = NULL; if (sqlite3_open([file UTF8String], &database)==SQLITE_OK) { ...

Archive a NSMutableArray

I need to archive a NSMutableArray which is being controlled by an ArrayController. I tried this: [NSKeyedArchiver archivedDataWithRootObject:array]; But I got this error: *** -[NSKeyedArchiver dealloc]: warning: NSKeyedArchiver deallocated without having had -finishEncoding called on it. How may I solve that please? ...

Why do my xcode builds always go to the iPad simulator instead of the iPhone simulator?

I just installed the latest SDK from Apple so I can start learning iPhone / iPad app development. However, I'm having a stupid issue: all my builds get run in the iPad simulator instead of the iPhone simulator, and I have no idea how to change it. ...