I've got a timestamp as a string like:
Thu, 21 May 09 19:10:09 -0700
and I'd like to convert it to a relative time stamp like '20 minutes ago' or '3 days ago'.
What's the best way to do this using Objective-C for the iPhone?
...
It seems like the best approach is to use NSToolbar. However, it is not obvious to me how to make an NSTextField within an NSToolbar flexible in terms of width. Is this possible? The default behavior of the textfield is to remain a constant width, even if the toolbar is resized.
...
This concept seems to trouble me. Why does an NSError object need its pointer passed to a method that is modifying the object? For instance, wouldn't just passing a reference to the error do the same thing?
NSError *anError;
[myObjc doStuff:withAnotherObj error:error];
and then in doStuff:
- (void)doStuff:(id)withAnotherObjc error:(...
How would you make a Outline view able to be re-ordered (dragging to move the position of a row) like a Table View. At the moment when I try and Drag a row it just selects other rows. How can I make It re-orderable?
...
I would like to know how the Cocoa Framework got its name. I know the name comes from the cocoa-beans but I need to know more details for a little tutorial I am writing.
It's a very unusual name for a framework and I would like to know why this name was chosen.
...
I have a table column that I'm binding to a value in an NSArrayController. What I'm trying to do is display only a substring of the actual value in the array controller. The way I've been trying to do that so far is by creating an NSValueTransformer subclass, and then doing the string manipulation in the transformedValue method. Howev...
Hi,
The NSObject method performSelector:withObject:afterDelay: allows me to invoke a method on the object with an object argument after a certain time. It cannot be used for methods with a non-object argument (e.g. ints, floats, structs, non-object pointers, etc.).
What is the simplest way to achieve the same thing with a method with a ...
how can i add a custom view to the right click menu of every file in os x finder?
e.g. i want to display the image if it is an image type and do some custom action etc.
is this possible with c or objective-c? if yes how? (without using any available tool)
...
Hi,
Currently i create 2 views and on the first view, there is a next button, upon clicking it, it will goto the second view.
Then in the second view, i set some value in the label and when i click back, it will go back to the first view.
Problem: now i am back in the first view, if i click the next button again, the label value i s...
I am a complete newbie to XCode, so I have been climbing the Quartz2D learning curve. I understand that a view's drawRect method is called whenever a refresh of the view's graphics is needed, and that the setNeedsDisplay method activates a redrawing.
But what I can't find is a clear explanation of the relationship between the graphics...
The following code creates me an array of all my contacts in my address book by first name and last name. The problem is, I have one contact that keeps showing up with an empty first name and last name. I can't find that contact in my actual address book. Can anyone suggest how to debug this to figure out the source of the mystery ghost ...
I've read in several books... and online... about immutable and mutable strings.
They claim "immutable strings" can't be changed.
(But they never define "change".)
Which of these NSStrings could be changed without using NSMutableString?
The string contains "catfish"... and I later try to change it to "cat".
(Same letters, just shorter....
How to round a number to end in 50 in obj c or c++ / cocoa?
I am writing a tax program, for the final lookup i have to round the income to end in 50 before i apply the tax rate.
The only alternative i can think of is string modification, but im shaky in that area,].
...
Hi to all,
I have created save.plist in resource folder. I have written some data within that directly (without using coding). I am able to read that data but I cant able write through coding into the same save.plist. By using following code I am trying to write the data but it get stored within my .app plist.
The code is here
NSString...
NSArray has useful methods to find objects for specified indexes
// To find objects by indexes
- (id)objectAtIndex:(NSUInteger)index
- (NSArray *)objectsAtIndexes:(NSIndexSet *)indexes
// To find index by object
- (NSUInteger)indexOfObject:(id)anObject
However, I want to get NSIndexSet (multiple indexes) for given objects. Something ...
The following concerns an iPhone app.
I want to use a singleton to handle an asynchronous URL request. I've got that covered but what is the best coding practice way to tell the singleton where to send the response when it is received? I need the response to be returned to the class which originally called the singleton.
Could I pass a...
If I have a directory in my Xcode project (not a Group), which is added to the main target, and compile it, how do I instruct an NSViewController to initWithNibName:bundle: a nib file inside that directory?
I've tried [viewController initWithNibName:@"FolderName/NibName" bundle:nil], but that doesn't work. Neither does without the folde...
I've just been reading up on how to properly fail in an init method and the docs seem to disagree with each other. One recommends throwing an exception while the others recommend cleaning up and returning nil. What's the current best practice here?
...
I'm writing a plug-in for a piece of software that takes a big collection of items and pops them into HTML in a WebView in Cocoa (which uses WebKit as its renderer, so basically you can assume this HTML file is being opened in Safari).
The DIVs it makes are of dynamic height, but they don't vary too much. They're usually around 200px. A...
I'm working on a Cocoa project using Core Animation and I've got a custom view that is displayed in two windows. It always shows up in one window, but sometimes does not show up in the other window when I start up the application. So far as I can tell, it is completely random. Here is the code I call when the view is initialized. It ...