Statically-typed languages and dynamically-typed languages in principle seem like opposite concepts. However, how can a language like Objective-C for example be both of these things at once? It seems to me that Objective-C is more static than dynamic. Can somebody explain how this is possible?
...
I am having an issue with NSDictionary returning null for an NSString even though the string is in the dictionary. Here is the code:
- (void)sourceDidChange:(NSNotification *)aNote {
NSDictionary *aDict = [aNote userInfo];
DLog(@"%@", aDict);
NSString *newSourceString = [aDict objectForKey:@"newSource"];
DLog(@"%@", newS...
Does a method which I check for with respondsToSelector have to actually exist?
What if I only define it in the interface part and fail to implement it? I'm looking at a poor-man's virtual function in Objective-C.
...
I create a second thread to call a method that downloads several images using:
[NSThread detachNewThreadSelector:@selector(downloadImages) toTarget:self withObject:nil];
It works fine but I get a long list of leaks in the log similar to:
2010-04-18 00:48:12.287 FS Companion[11074:650f] * _NSAutoreleaseNoPool(): Object 0xbec2640 of cl...
I want to write a standalone function in Objective-C; so essentially a C-style function, with Objective-C calls in it. For example:
NSString* someFunc()
{
NSString* str = [[NSString alloc] init];
return str;
}
I declare the function in a header file, and define in it a .m file. However, the function doesn't appear to be compiled in...
I have other pages within my app preferences which are stored as separate files within the settings.bundle.
It has come time to localize my app and I can only seem to get the Root values to localize. I was wondering whether there was a trick?
The following image shows that my second screen is stored within a file called "MyPrefs.plist"...
I have an app with tabbar and webview. I'm trying to make the app come back to default url each time user taps the bar. Right now I'm intercepting taps and launching a method, however it's not affecting my webview (it's not loading the page). The method works properly when called from the class, but not when it's called from my app deleg...
Hello I'm creating an os x application for which I try to add a remote interface. For this I need to be able to send mouse down and mouse up commands to the window of my application.
I found code with which I can successfully do this, it looks as follows:
int mask = 0x100;
NSEvent* eventMouseDown = [NSEvent mouseEventWithType:NSLeftMou...
Hello guys!
I need to display 10 - 1000 images on a UIScrollView. Paging is enabled. So every page of the scrollview is an image, it is an uiimage. I can load 10 images to 10 uiimages which stays in the memory, but with 1000 images I have problems on the iPhone or on the iPad. I am trying to unload and then load the images when I am doi...
I am setting up an application using the MVC model and I have a query regrading the flow of information from the UI to the data model. What I need to do is place data from the UI in the model, what I have done is write a method in the view which collects the required data in an object and then passes it to the model. The model then takes...
Sometimes I need to find out if an object will really be released. I could use Instruments of course, but that takes much time, and I have to search into millions of objects, so I used to do this:
-(void)release {
NSLog(@"I'm released");
[super release];
}
But the problem is: is this safe to do? Can I get any problems when I o...
I know how bitwise AND works,but I don't understand how does (sourceDragMask & NSDragOperationGeneric) work here,I don't get the point.Is there anyone can explain to me?Thanks a lot.
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
{
NSPasteboard *pboard;
NSDragOperation sourceDragMask;
sourceDragMask = [send...
I'm wondering how to go about monitoring network traffic on my Mac.
Like the way activity monitor does it, showing the bytes / packets in and out.
I know it's a bit vague, but I'm unsure of the best place to start.
EDIT: I forgot to mention, I'm wanting to do this in code, not use an existing piece of software.
...
In the code below I'm making a new NSString with alloc and initializing it with the contents of some file. Because I'm calling alloc I know it's my responsibility to call release on the string when I'm done. But what about the variables "lines" and "line"? Since the method "componentsSeparatedByString" does not start with the word "ne...
In objective c (iphone) are the nib files (xib) the View part of the MVC?
When you set a property of an object in IB where is that actually stored in the xib file?
...
Hello experts!
Let's say I add a new view to my UIWindow
[windowRoot addSubview:MyNewView.view];
Is it possible to retrieve the name of that view later on if
I have reference to windowRoot?
Something like:
[windowRoot getCurrentViewName]
Thank You
...
Hi all!
I learn Cocoa Touch several days, and today have stuck while looking for way to implement a custom event. Event that I can see in Connection Inspector for my UIView subclass.
What I have:
There are a UILabel and MyView:UIView on MainVindow. MyView contains a UISlider. Interfaces for Controller and MyView
// Controller.h
@inter...
Hi,
I know that there are functions in the objective-c runtime that allow you to create objects directly, such as class_createInstance. What I would like to know is if anything actually uses these functions other than the root classes' (NSObject) alloc method. I think things like KVC bindings might, but those aren't present on the iPho...
I have a struct in ClassA and want to assign it to the same struct in ClassB (the two structs are the same with different names). ClassA and ClassB are view controllers. Basically, I need to pass this struct to another class. However, structs don't seem to be exposed as members, which means I can't access them. Here is ClassA's struct...
I have my user preferences set to display in the system-settings application BUT I want to give them the option of adding additional settings.
Specifically, the user has a group 'favorites' in the settings bundle and they then can put in the details of their three favorite contacts. However, I want to give the user the option of adding ...