I've been modifying some code to work between Mac OS X and iPhone OS.
I came across some code that was using NSURL's URLByAppendingPathComponent: (added in 10.6), which as some may know, isn't available in the iPhone SDK.
My solution to make this code work between OS's is to use
NSString *urlString = [myURL absoluteString];
urlString ...
Currently when I open a file with my program I can select files on a server by clicking on the server name in the sidebar in an NSOpenPanel and then selecting the file. No problem, this works fine for using the file as long as the shared directory is mounted. I get a path like "/Volumes/SHARENAME/filename.bla".
My question is how do...
I know you shouldn't use this to decide whether or not to change an array:
if ([possiblyMutable isKindOfClass:[NSMutableArray class]])
But say I'm writing a method and need to return either an NSMutableArray or an NSArray, depending on the mutability of possiblyMutable. The class using my method already knows whether or not it's accep...
Brand new to Cocoa and I'm trying to figure out how to copy an NSAttributedString to the pasteboard. I've looked in the docs and not sure if I'm supposed to use a NSPasteboardItem or not.
Here's what I have to copy a regular NSString:
NSPasteboard *pb = [NSPasteboard generalPasteboard];
NSArray *types = [NSArray arrayWithObjects:NSStri...
i have this code
#import <Foundation/Foundation.h>
int testint;
NSString *teststring;
int Test()
{
NSLog(@"%d",testint);
NSLog(@"%@",teststring);
}
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
testint = 5;
NSString *teststring = [[NSString alloc] initWithS...
I would like to separate my string by spaces, commas, periods (ie. punctuations). I am using:
[myString componentsSeparatedByString:@" "];
to separate by spaces, but need to be able to split by punctuations as well.
...
Let's assume I have the string
NSString* myString = @"Hello,";
How can I remove the comma without leaving a space? I have tried:
NSString* newString = [myString stringByReplacingOccurrencesOfString:@"," withString:@""];
and
NSString* newString = [myString stringByTrimmingCharactersInSet:[NSCharacterSet punctuationCharacterSet]];
...
When an item is selected in the source list it is highlighted in blue. When another element on the window is selected, however, the highlight becomes a lighter blue as the source list is no longer focused.
I would like to change the behaviour so the item is always the darker blue, the same behaviour as seen in Finder.
...
If you search for something that opens Preview.app (e.g. a PDF file) in Spotlight, the application not only opens the file but actually copies the Spotlight query into the application's search field (for deeper search). iPhoto and Mail.app also do this.
This is a really nice feature. Unfortunately, Apple does not document how it's imple...
In Objective C (Cocoa) I have an app running with a modal sheet, but I want to allow the app to quit even when the sheet is displayed (contradicting the definition of modal I think, but I like the animated effect of modal sheets).
I'm already using the -setPreventsApplicationTerminationWhenModal method and it works fine, but I'm wonderi...
Hi,
I have a simple class with an NSMutableDictionary member variable. However, when I call setObject:forKey I get an error ('mutating method sent to immutable object'). The source of the problem is obvious from the debugger -- my NSMutableDictionary is actually of type NSDictionary.
I must be missing something incredibly simple but c...
I have developed a launchAgent in cocoa. It works fine for me on dev environment, by placing the plist file in location /Library/LaunchAgents/.To distribute and install this on other laptops, I created the package using package maker tool. As part of installation process I want to change permission of the plist file and copy it to /Libra...
Hi, I am trying to develop a cocoa application that requires to read highlighted text from any application. But so far I cannot find any decent solution because the accessibility API isn't always work. (e.g. Firefox) Does anyone know how it is implemented in text-to-speech included in Leopard?
I have found this SO question but it isn't ...
Hi,
I (apparently) manage to make a ftp connection, but fail to read anything from it, and with good cause: I don't reach the reading until the connection has timed out.
Here's my code:
header:
NSInputStream *iStream;
NSOutputStream *oStream;
implementation:
NSHost *host = [NSHost hostWithAddress:@"127.0.0.1"];
[iS...
I am need to parse a pdf file. I would like to use objective-c and Cocoa classes to do so, but I need the resulting application to run on Linux. Is this possible? My experience to Objective-C revolves around the iPhone so I'm relatively new to Cocoa. Thanks.
...
My application utilizes approx. 50+ .plists that are used as NSDictionaries.
Several of my view controllers need access to the properties of the dictionaries, so instead of writing duplicate code to retrieve the .plist, convert the values to a dictionary, etc, each time I need the info, I thought a model class to hold the data and sup...
I'm trying to set up a print dialog, so that if the user tries to save to PDF, it gets a reasonable filename.
I currently have:
NSPrintInfo* pi = [NSPrintInfo sharedPrintInfo];
NSMutableDictionary *dict = [pi dictionary];
[dict setObject: name forKey: NSPrintSavePath];
[dict setObject: name forKey: @"NSPrintSavePath"];
NSPrintOperation...
What does this mean?
* Terminating app due to uncaught exception
'NSInvalidArgumentException', reason:
'* -[NSPathStore2
hidesBottomBarWhenPushed]:
unrecognized selector sent to instance
0x1cd3d0'
...
Let's assume I can have the following strings:
"hey @john..."
"@john, hello"
"@john(hello)"
I am tokenizing the string to get every word separated by a space:
[myString componentsSeparatedByString:@" "];
My array of tokens now contain:
@john...
@john,
@john(hello)
I am checking for punctation marks as follows:
NSRange textRange...
I have a NIB that contains a UIView.
I have another NIB that contains a UITableView.
How can I load the UITableView NIB inside of the UIView in my other NIB?
...