cocoa

NSXMLDocumentTidyHTML doesn't tidy some XHTML validation errors.

I want to grab text from a list of web pages. I've done a bit of experimenting and found that the best way for my needs is via WebKit. Once the source of the page has been grabbed, I want to strip out all the HTML tags, by using the technique in this comment. Here's my code: - (void)webView:(WebView *)sender didFinishLoadForFrame:(Web...

Why does Spotlight sometimes not run my query?

I'm playing around with the Spotlight API, both the Carbon and Cocoa versions, and I seem to have the same problem crop up every once in a while: The query never runs, and never fires any notifications. However, I want to stress that most of the time it does run, so something strange is going on. I'm not writing any particular app. This...

NSNotification userinfo example?

I have an array of objects that are positioned using CGPoints . At certain times in my app, an object in the array needs to notify other non-arrayed objects of its position. I understand that NSNotification is the best way to go, but I cant find a decent example of a 'sender' and 'reciever' for the notification that wraps and unwraps a C...

Countdown Timer

I'm trying to create a countdown timer that takes countdown, an IBOutlet connected to a textfield, from 60 seconds down to 0. I'm not sure A. How to limit the repeats to 60 and B. How to decrement the countdown in advanceTimer: - (IBAction)startCountdown:(id)sender { NSTimer *countdownTimer = [NSTimer scheduledTimerWithTimeInterval...

Display PlaceHolder Text

I have a countdown timer textfield that displays 60 as a placeholder (grey). When I start the timer, it goes black and starts counting down. At the end, I invalidate the timer and set the countdown textfield back to 60. Of course, it's black now. How do I get it back to the placeholder text of 60 (meaning that it's grey) without reso...

Loop through similarly-named Controls

I have view0 through view25. I don't particularly want to have a 25-case switch, so is there a way to do something like this? - (void)modifyViewNumber:(int)number { [view*number* dosomething]; } ...

How to create an NSString with one random letter?

Hi, I need to create an NSString that has a single random uppercase letter. I can get random int's fine, and I could construct a C string from it and then make the NSString, but I imagine there has to be a better and more cocoa-ish way. Thanks! ...

Removing a binary attribute's data(used in NSImageView) in Core Data entity

Hello guys, I have an optional binary attribute: image , containing an image for my entities. In the interface, I have NSImageView (Image Well), and a "Remove Image" button. When the image removing button is clicked, I do: - (IBAction)saveAction:(id)sender { NSError *error = nil; if (![[self managedObjectContext] save:&error]) { ...

Is it okay to use an NSLocalizedString as a key in a dictionary?

I want to use my dictionary keys for output in a grouped table. This has to be localized with all my other content. Can I use an NSLocalizedString as the key? NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys: first_array, NSLocalizedString(@"First Array", @"The First Array"), second_array, NSLocalizedString(@"Seco...

NSURL analog to CFURLCreateCopyAppendingPathComponent?

Playing with URLs, more specifically building them incrementally from other, discovered URLs. In doing so, I'd like to stay using NSURL objects instead of manipulating NSStrings, just to gain the added sanity checks and url-specific methods from the URL class. Unfortunately, it seems that there is no way to get the following to join to...

Why is highlight:withFrame:inView: in an NSTextAttachmentCell subclass never called?

Hi, I am subclassing NSTextAttachmentCell and it works very good so far. The problem is to highlight the cell in a different color when the cell is selected or highlighted. The documentation of NSTextAttachmentCell points to the method highlight:withFrame:inView:. But this method is never called. Any idea? As a workaround I'm overrid...

Does [NSStepper setMinimum/setMaximum] also set the value?

Given an NSStepper with a minimum/value/maximum already set, if I set the minimum to a valued between value and maximum, will the NSStepper's value change? I know I could just try it, but that would only tell me for my current OS, and I can't find any documentation to indicate one way or the other. ...

didSelectRowAtIndexPath not working on sdk 3.0

Hi, i was working on an app in sdk 2.x and every thing was working fine. but now i have updated my sdk to 3.0 and found didSelectRowAtIndexPath of tableview is not working. any one know why its heppning???? Thankz in Adv. Muhammad Usman Aleem ...

Can you write Cocoa apps with HTML/CSS and Javascript?

I was thinking, would it be feasible to create a Cocoa app that is essentially just a an interface with a web view? Or is there some serious limitation when doing something like this? If it is "feasible", would that also mean that you could do the same for Windows applications? ...

Core Data Migration really Slow, Why does it happen at all?

I'm developing a desktop Mac OS X App that saves its very simple data into SQLite with Core Data and a companion mobile App for iPhone that simply needs to read data from the desktop App. Although they share the same Managed Object Model when I load the SQLite database on the mobile app the data takes several seconds to migrate the data....

NSTableColumn bound to a BOOL value

i have NSTableView bound to an NSArrayController. in my model i have a BOOL field. i'm trying to bind that value to the column. it displays correctly (1 where value is YES and 0 where value is NO), but it's readonly. =( when i'm trying to edit a value i can't submit it -- when i press enter nothing happens, setter is never invoked. colum...

Is there a better way to put a bunch of stuff in NSUserDefaults?

I'm confused about NSUserDefaults on the iPhone. I come from a C / asm background and the Objective-C stuff has been a learning experience. I'm currently using NSUserDefaults to store some strings (for the names in a highscore table). I want to start implementing a "Save Game" type feature so if the user gets a call or exits out of th...

Cocoa Distributed Objects, Long Polling, launchd and "Not Responding" in Activity Monitor

Scenario: I have a Distributed-objects-based IPC between a mac application and a launchd daemon (written with Foundation classes). Since I had issues before regarding asynchronous messaging (e.g. I have a registerClient: on the server's root object and whenever there's an event the server's root object notifies / calls a method in the c...

Determining Which Instance Self Is

I have a gameboard with 25 tiles of NSView subclass myGameTile. In mouseDown: I want to figure out what tile I clicked on and set an ivar to that value. i.e. If I clicked on tile 12, set myTile to 12. My problem is figuring out in mouseDown: whether it belongs to instance 12 or instance 25. What ways are there to do this? ...

Blank process name for OSX Cocoa application?

I'm developing an OSX application (Clarke) that runs with LSUIElement set (system menu only - no tray icon, doesn't appear in cmd-tab). It works totally fine, but someone just pointed out that it has a blank process name in the Activity Monitor listing. Just says nothing. Everything else in there has a name. Even other apps running at L...