objective-c

Swear Filter in Objective-C: Needed for iPhone App

Need to filter our swear words that are inputted to the iPhone app and inserted to our database. I'd like to catch this before passing to our database. Currently, I was using: stringByReplacingOccurrencesOfString:@"swear" withString:@"" but this seems inefficient to list 20+ words that need to be filtered. What's the best way to app...

objective-c divide always returns 0

Something really weird is happening. float p1 = (6 / 100); NSLog(@"p1 = %f", p1); With those two lines of code I get the following output: p1 = 0.000000 Why is a simple devide with static numbers not working! I have so much work to do to deal with divide not working! What he heck, am I crazy? ...

self.prop=nil; vs. [prop release];prop=nil;

If I am using synthesized properties, then why wouldn't I simply say : self.property = nil; This will release the ref count, and make sure I don't have a dangling pointer. Seems straightforward, and yet 99% of code I see seems to do it this way: [property release]; property = nil; and yes, in most cases they are properties. I get...

does copy/mutableCopy operation increment retain count value ?? (Objective C)

does copy/mutableCopy operation increment retain count value ?? (Objective C) ...

NSFilemanager one directory back ?

Hello , i want to know if there is a way to get the previous directory when working with NSFileManager... This can be probably done by appending '..' to the current directory ([[NSFileManager defaultManager] currentDirectoryPath] ) , but it's not a good idea at all :( Is there another effective way to do this ? ...

SplitView Controller Menu Overlay

Hey there guys, I'm trying to create a menu overlay system on top of a split view application for the iPad. The menu overlay systems is suppose to support a few buttons, one of which will make the overlay disappear and show the SplitViewController. My application delegate is as follows: UIView *view = [[UIView alloc] init]; [view add...

How to work with CALayer: Trying to draw a Layer in my Application

Hi Friends , I am trying to add a layer(CALayer/CGLayer) to my application. So i googled for that and tried. When i am trying to create a CALayer using the following code -(void) awakeFromNib{ CALayer *layer =[CALayer layer]; } But it is showing some warning when compiling.[Warning: No +'layer' method found] I add the framework Q...

Best datastore for storing 20,000 items to be queried by UISearchBar

I need to store 20,000 records that are brief (map identifiers to names) and allow the user to search for one either by ID or name in a UISearchBar. Approach 1 (Core Data): To conserve memory, I tried implementing this with CoreData with SQLite as the backend but found that storing 20,000 records is slow when the initial import is done....

Understanding NSString comparison in Objective-C

Both the following resolve to True: 1) @"foo" == @"foo" (is True) 2) NSString *myString1 = @"foo"; NSString *myString2 = @"foo"; myString1 == myString2 (is True) However, there are definitely times where two NSStrings cannot be compared using the equality operator, and [myString1 isEqualToString:myString2] is required instead. Ca...

CFURLCreateStringByAddingPercentEscapes crashing app on line breaks

Code: NSString* string3 = (NSString*)CFURLCreateStringByAddingPercentEscapes(NULL, (CFStringRef)tvQ.text, NULL, (CFStringRef)@":/?#[]@!$&'()*+,;=", kCFStringEncodingUTF8); My code is working to pass special characters properly via URL to my database, however, if I insert data with linebreaks, it seems to break my app and crashes. Any ...

downloading large amount of images ipad - memory leak?

I am have an app I am writing that will need to download alot of images, possibly 10,000. Right now I can get to about 3000 before I run out of memory and the app crashes, just depends on the image files sizes. I am downloading them on a background thread and showing the progress to the user. I wrote a helper class thatI am accessing ...

How to make my iphone app icon update like the weather app icon?

I have an application that I'm currently building that requires me to display a visual update on the application it self. example: The weather app displays 14 degrees celcius and some clouds as its application icon. When the weather changes there is an update to the way the icon looks without having to open the weather app. The applicat...

iPhone Function, Swap Arrays

Hi I want to put this into a function. NSMutableArray* weekArray = [[NSMutableArray alloc] init]; [weekArray addObject:@"Before School"]; [weekArray addObject:[NSString stringWithFormat:@""]]; [weekArray addObject:[NSString stringWithFormat:@""]]; [weekArray addObject:@"Break"]; [weekArray addObject:[NSString stringW...

Parent VeiwControllers of ViewControllers

Hi guys, My main view PlayGameViewController has a subview (actually 2 of them) called CardViewController. CardViewController creates some buttons programmatically -(void) initialiseButtons { NSLog(@"initialiseButtons %d",totalButtons); int ypos = playerImage.frame.origin.y + playerImage.frame.size.height + 42; for(...

How to assign a value or title to a UIbutton instance so I can access it when I press the button?

Hi, I want to create a basic app where you have 8 numbered buttons, with a randomly generated number on each. You are given a total value, and have to click on buttons whose numbers add up to that value. I need to show which buttons have been 'used' already (I hope to use the selected state for that, as I am using a custom button). W...

adding ShareKit to my project, won't compile - 4,448 errors

Hi, I can get the ShareKit demo from github to compile using the iOS 4.1 SDK, but when I import it into my project exactly how it's described on the ShareKit site, after compiling I'm getting 4,448 errors. It looks like I'm missing a framework, but I have the required frameworks listed. Maybe there's some kind of framework conflict. Here...

simple question about assigning float to int

This is probably something very simple but I'm not getting the results I'm expecting. I apologise if it's a stupid question, I just don't what to google for. Easiest way to explain is with some code: int var = 2.0*4.0; NSLog(@"%d", 2.0*4.0);//1 NSLog(@"%d", var);//2 if ((2.0*4.0)!=0) {//3 NSLog(@"true"); } if (var!=0) {//4 N...

iOS 4.1 OpenGL ES 1.1 not drawing Texture

For some reason my texture are not drawing, even though my code looks exactly the same as an old project that did. So far, the vertexes and TexCoords look fine, as I am having white squares being drawn, where the texture should be drawn instead. The process so far goes, I load up a Contoller and in loadView, I glEnable(GL_TEXTURE_2D); ...

Xcode change global variable for each target

Hi there, I have a series of targets, and each one looks at a global variable I am currently storing in a constants file for the name of the directory in which that app's resources live. However, this means that I have to change this value each time i change the target, which is a terrible process. What is the best way to change that ...

Possible to limit results returned by NSArray filteredArrayUsingPredicate

I'm using [NSArray filteredArrayUsingPredicate] to get an array of objects that match certain conditions within an original array of 20,000 objects. Is it possible to limit the number of results that this method returns in order to speed it up? This would be similar to the LIMIT clause in SQL. Thanks. ...