I'm trying to do something really trivial: A macro that takes an string and prints that to NSLog.
Like this:
#define PRINTTHIS(text) \
NSLog(@"text");
However, when I try to pass a string to this guy I end up getting "text" printed to the console. Aren't all variables replaced on a string-level inside the macro? How to do that ri...
Example: When my method -fooBar gets called, I want it to log in the console which other method of which other class called it.
Right now, I only know how to log the method name of fooBar itself and it's class, with this:
_cmd
[self class]
Is this possible to figure out?
...
I want to implement just like interface builder segmented control, and click it to change views , I don't know under the segment if a NSBrowser or not. and how to change the view , can you give me some sample codes or a demo? Thank you very much!
...
I've got an app that initially loads in one view controller for a period of time before it's replaced by a UINavigationController (and its corresponding root view controller) in the Window's view. Once the app is being managed by the Navigation Controller I am releasing the previous View Controller and its View. It's difficult for me to...
I have seen a lot of programs had some buttons or images in the vertical or horizontal scrollview table header or bottom and click it to invloke some events, But I have searched interface builder library and not found some widget I can used , how these programs to implement it ? Thank you very much!
...
Is there is a Cocoa framework for windows or a interface builder for windows like we have in mac?.
Thanks.
...
Is there a way to find out if the user is in the Exposé mode? (i.e., all windows are being shown.) Thank you.
...
This is for practise. I try to build something similar to NSLog. Currently I have this:
#define LogThis(info) \
[[MyLogger sharedLogger] logThis:info];\
- (void)logThis:(NSString*)info {
fprintf(stderr, [[NSString stringWithFormat:@" %@\n", info] cString]);
}
Currently all I can do is pass a simple @"string" to it, but no f...
I try to make a useful macro for logging. But I find that NSLog and all other sort of macros that carry textual information with them simply distract a lot from the code.
Is there any way to "hack" Xcode in a way that it will interpret something like
/*** do this because of that ***/
as a macro call, which results in calling NSLog, ...
Example: I run my app in the simulator. Then I want to figure out what exactly is going on when I touch a button. Normally I would first have to find out where the entry-point of all this madness is in order to place a breakpoint. But now lets assume my app has 700 classes and it's incredibly complex, with more than 12.000 methods. Chanc...
For example, I print out something to the console using NSLog. Is there a way to pass all the current method's arguments to NSLog or any other function or method without looking at each of them explicitely?
For example, I have already a macro that prints useful information to the console when I just put LOGME in my code. The macro will ...
XCode:Run>Show>Breakpoints
I've added the obligatory [NSExceptionRaise] and objc_exception_throw yet when I close the Breakpoints window and then return XCode adds a third breakpoint: -[NSExceptionRaise]. Does this mean [NSExceptionRaise] is wrong and I should delete it? Or are they both helpful? If so in what way are they functionally...
I have a NSURL to a local file with no base url. I want to change the base URL to another local directory, with the relative path being in respect to that URL.
For example
NSURL *path = [NSURL fileURLWithPath: @"/Users/username/Desktop/Photos/Photo1.jpg"];
Now, say I want to change the base part to /Users/username/Desktop/SomeFolder,...
I made a little cocoa app that brings up an IKPictureTaker and saves a picture to a file if you press the set button. Currently, if you press esc or Command . the window picture taker will close. Is there a way to disable this behavior?
...
Hi,
I'm dynamically adding rows to an NSTableView. When I issue [table reloadData] I can see the scroll view move and if I move it by hand I can see the new value on the table. But how can I scroll it automatically?
...
I am not sure if this can be done -- it looks like it should be a straightforward thing but I keep getting "the entity Sale is not key value coding-compliant for the key "@sum"."
I using "@[email protected]" for the Table column value binding.
I am doing it right, or what is the right way to do this?
...
Hi,
I've got an NSTextView, inside an NSScrollView, and I want to scroll it to exactly where it used to be after repopulated the NSTextView with new data. So far, I've tried variations on the code below, but it never gets it quite right.
What I need is a setDocumentVisibleRect method, but there isn't one.
NSRect oldVisibleRect = [[[se...
Hi,
I would like to be able to change the OSX services that my application provides based on the current user's preferences (like adding more, changing the name,...). This basically means modifying the Info.plist (NSService key), but I don't think it is a good practice when an application modifies its own Info.plist while running, right...
The IMP type in Objective-C represents a function pointer, as far I as understand. Is there any way to make an IMP from a block pointer? Thanks for your ideas.
UPDATE: Thanks, @bbum, for your great solution. I haven't modified my code to use it yet, but everyone can see the fruits of my labors here: A new metaclass for Objective-C.
...
I have a simple iPhone app with several sounds already playing. However, one in particularly won't. The code block I've hacked up is:
NSString *soundPath2 = [[NSBundle mainBundle] pathForResource:@"gameover" ofType:@"wav"];
NSURL *soundFileURL2 = [NSURL fileURLWithPath:soundPath2];
NSError *err;
AVAudioPlayer *sound2 = [[[AVAudioPlaye...