about NSMutabuleArray
ruby code irb(main):001:0> ary = ["a", "b", "b", "a", "b"] irb(main):002:0> ary.uniq! I want to write same code in objective-c. ...
ruby code irb(main):001:0> ary = ["a", "b", "b", "a", "b"] irb(main):002:0> ary.uniq! I want to write same code in objective-c. ...
I have this piece of code, which copies a plist file to the ApplicationSupport directory in the users folder. NSString *resourcePath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:kAutonumberPlist]; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES); ...
I am getting the following warning: assignment from distinct objective-c type How do I fix this? ...
I am wondering why in the following code the static integer does not stay 0? Is it because in objective-c classes are objects, too and the CoolClass Class is kind of kept around like a singleton? @interface CoolClasss : NSObject +(void)staticMethod; @end @implementation CoolClass static int integer=0; +(void)staticMethod { N...
I am unsure about the correct definition of transient properties: One can define transient properties in the object model and then calculate them when needed in the related class. But things work just as well if you specify a class and define arbitrary getter methods for any transient property without declaring it in the object model (...
Triggered by Mike Ash’s newest article “Dangerous Cocoa Calls” from his great Friday Q&A series, I want to know which are the things in Cocoa that made your code stumble. Mike has compiled a great list of evil API uses that are mostly about thread and exception safety. I’m sure that there are more hidden pitfalls that Cocoa programmers s...
Hi, I'm writing an application for Mac. I need some code which generates a hash from a string. I need to create these hashes: MD2 MD4 MD5 SHA-0 SHA-1 How can I do this? Thanks. ...
When ever I set an image for a UIImageView in IB and simulate the interface the buttons and stuff show up but the image view doesn't. ...
Hi guys, I'd like to have a method be executed after the current method has passed and the UI has been updated. For that purpose, I'm using [object performSelector:@selector(someSelector) withObject:someObject afterDelay:0.0] right now. According to Apple's documentation, this creates a NSTimer which will then trigger and append the sel...
I am working on a menu of an application. The problem now is that i can't get the UIScrollView working. The UIScrollView is in a Xib file. It loads normal but when I try to scroll it crashed. I think the problem is that I use a UIViewController since when I remove the delegate not to itself it is working. Now I got: scrollView.delegate ...
I have a custom view that draws an CGImage using: - (void) drawImage { CGContextRef context = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort]; CGRect imageRect = {{0,0}, {CGImageGetWidth(image), CGImageGetHeight(image)}}; CGContextDrawImage(context, imageRect, image); } It looks like the memory used by the ...
I would like to create a portable library for iPhone, that also could be used for other platforms. My question is the fallowing: Does anyone knows what is the best to be used on the iPhone: Objective-C or Objective-C++? Does it works with C++ the same way as Objective-C with C or not? Reasons: Objective-C is a superset of C, but Objec...
Hi, I'm having an NSString like this: music that rocks.mp3 e99a65fb The problem is that between the filename (musicthatrocks.mp3) and the CRC32 checksum (e99a65fb) there could be many more spaces then one. How can I split the line into an array? I thought of using componentsSeparatedByString, but my problem is that the filename ca...
Hi all, I've been working on a new app, and when I run it on the simulator, it's VERY slow. There's nothing fancy in the app, just UINavigationControllers and text. The slowness only occurs if I launch the app from Xcode (with or without debugging on, doesn't matter). If I run the app on my iPhone or launch it directly from the simulator...
In my app I need to display the appropriate currency symbol for the user's current locale. I'm not displaying currency values, just the symbol. Any ideas? ...
I need to figure out how to get two OpenSSL functions for iPhone. I'm trying to keep it so I don't need another dylib, because I don't want Apple to reject my application for something so silly. Anyways, I have an app that access an API, not one of my APIs, so I can't really change it, and also, I don't want anyone to know my public key...
Can anyone tell me how I refer to these, is the first a system managed object and the second a user managed object, whats the terminology I should be using in objective-c / cocoa to refer to each of these? 01 +(Planet *) planet { gPlanetCount++; return [[[self alloc] init] autorelease]; } int main(int argc, const char * argv[]...
I am having an issue with Core Data... here is my situation: I have a Restaurant and that restaurant has a category which is a to-many relationship and the category also has a to-many relationship back to the restaurants for example: McDonald's has a category of: (category) Fast Food, (category) Local Category (Fast Food) Type: (NSStr...
This loads the image on the simulator but not on the device: UIImageView *splashImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"SplashPH.png"]]; [self.view addSubview:splashImage]; Any help appreciated // :) ...
Working in a ViewController that has a few views which were added to it as subviews and I have a touchesBegan method: UIImageView *testImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"test.png"]]; testImage.frame = CGRectMake(0, 0, 480, 280); [self.view addSubview:testImage]; - (void)touchesBegan:(NSSet *)to...