I have cocoa application running on OS X. I have used NSLog for debugging purpose. Now I want to redirect the log statements to file instead of console.
I have used this method but it results logging in Console as well as in file.
- (BOOL)redirectNSLog
{
// Create log file
[@"" writeToFile:@"/NSLog.txt" atomically:YES encoding:...
I made a Cocoa program that lets the user enter their name in NSTextField. When the user presses a button, another textbox is supposed to say Hello to them. This is the code I tried to use.
NSString *myString = [textField stringValue];
[textView setString: @"Hello " myString];
This does not work. How can it be fixed?
...
Hi,
I assume according to "Cocoa design patterns" book i'm reading that the retain function is implemented using something like this :
- (int)retainCount
// Returns the receiver's current reference count
{
int result = 1; // receiver not in table, its count is 1
void *tableValue = NSMapGet(
[[self class] _myRefCountMapTable], self);...
If I run the following code:
[textView setString: [ NSString stringWithFormat: @"Hello %@. Today is %@", [ textField stringValue ], [ NSDate date]] ];
it says
Hello Phenom. Today is 2010-07-06
02:37:43 -0700
How can I fix it so that it instead says
Hello Phenom. Today is Tuesday, July
6
...
Hi all,
I am trying to parse a PDF and extract catalogue from it. For this purpose I am using following code: -
CGPDFPageRef page = CGPDFDocumentGetPage(document, currentPage); //1
myContentStream = CGPDFContentStreamCreateWithPage (page); //2
myScanner = CGPDFScannerCreate (myContentStream, table, NULL); //3
CGPDFScannerSca...
Recipe example
RecipeAddViewController *addController = [[RecipeAddViewController alloc]
initWithNibName:@"RecipeAddView" bundle:nil];
addController.delegate = self;
Recipe *newRecipe = [NSEntityDescription
insertNewObjectForEntityForName:@"Recipe"
inManagedObjectContext:self.mana...
Hi, Im writing a server to receive key events from an iPhone. I can send a message from the iPhone and have my server display it, on the Mac, now i just need to translate that into a Key press, and simulate that press in Cocoa.
Could anyone offer me a starting point, as i guess this is quite low level.
Thanks
...
Trying to import a RSS feed into Core Data. Once they are imported, when trying to update the feed again afterwards, how do I most efficiently prevent duplicates. Right now it checks every item against the datastore during the parsing, which is not very efficient.
I looked into the Top Songs sample from Apple. It uses a least recently u...
Hi
I am developing a Cocoa application to embed a .swf file in a WebView and rotate the content of the Webview. The .swf file is an interactive flash file. Everything works fine, but when I rotate the content of the WebView, the drawing of the flash and playback get rotated, but not the interactive points of the .swf file. They stay in ...
Hi,
The Cocoa "Memory Management Programming Guide" document says:
You take ownership of an object if you create it using a method whose name begins with “alloc” or “new” or contains “copy” (for example, alloc, newObject, or mutableCopy), or if you send it a retain message. You are responsible for relinquishing ownership of objects y...
I am writing a MacFuse plugin, and would like finder to use the appropriate icons & launch the appropriate app when a file is opened.
It is not possible for me to add an extension to the file, so my only other option in Snow Leopard is the NSFileHFSTypeCode. I have reviewed all of the codes registered on my machine using http://www.rub...
Hi everybody.
I am trying to use Apple's example of using kqueue but the callback is never called unless I start observing the kqueue after the process starts. But the lifetime of the process is short and i need the code to work if the process starts before or after I start observing it.
...
Hi everybody,
i have a problem using dataWithContentsOfURL.
I'm loading some images from the internet in a loop.
The Problem is: if the image at the URL doesn't exist, dataWithContentsOfURL does NOT return nil as expected. The apple reference says it returns nil if NSData could not be created.
Here's the Code:
NSString *TermineImgFile...
I have a Core Data app that has a bug that causes the app to crash and I have not tracked down its cause yet. One of the results of the crash is that the next time the app is started up it can not open the persistent store used by the application previously. The following error is returned from the addPersistentStoreWithType: method:
...
I get a abort() which I am not able to 'catch' in my code.
Perhaps I am missing some understanding; can you give me some insight or perhaps help me with the abort() ?
Please note; the code works fine for thousands of users I have; but a very few (two now) have reported this crash.
First the code (simplified):
244: -(void)openBSDSocket...
I'm trying to draw equations to the screen. Not the graphs or sth just the equation, but in a "pretty" way (f.e. like they look on wikipedia ).
I've done some research but could find a "build-in-way", but maybe i overlooked something?!?
So i've decided to draw them by myself. I'm not very experienced, so don't blaim me if my idea is com...
I've got a super simple little OS X app with a minimal embedded webkit view that needs client-side SQL database support enabled. I've put the test app up on github but just can't get the client-side storage working.
I'm using Xcode v3.2.3 with the WebKit framework it provides, but have also tried using the webkit nightly without luck.
...
In Mac OSX 10.6, the NSErrorFailingURLStringKey userInfo dictionary key is deprecated in favor of NSURLErrorFailingURLStringErrorKey. I am trying to write my program to be portable to both Mac OSX 10.5 and 10.6. For the time being, I'm just using the old key--but my compiler is giving me annoying deprecated warnings.
// The following ca...
I am a great fan of code generation (from UML) and coming from the Java world, I wonder how I would implement automated bi-directional association management in Objective-C.
Image an association Partner <-> Address, one-to-many and navigable from both ends. What I would like to achieve is that if I append an Address to a Partner that Ad...
Hey guys,
I need a bit of help with NSTask. Also, I am new to Cocoa / Obj-C programming, so please bear with me. I am trying to make a directory. Then, remove it. So here is what I have so far:
NSLog (@"START");
NSTask *task;
task = [[NSTask alloc] init];
[task setLaunchPath: @"/bin/mkdir"];
NSArray *arguments;
arguments = [NSArray a...