objective-c

Emojis causing iphone to crash

Our iphone app has a chatroom where users can post comments. Recently, the chatroom has been crashing the app because users are adding emojis to their comments. I went to my server PHP script to not allow characters that aren't in the A-z0-9 range (I also allow around 30 punctuations characters) hoping that this would prevent the app/fee...

How to know if an object is autoreleased or not?

I'm getting a a bit annoyed about some objects being autoreleased without me knowing. It's probably a good thing that they are, but if they are, I want to know. The documentation doesn't say which methods autorelease objects, so I usually test my way forward, which in my opinion is silly. For example, [NSDate date] autoreleases the objec...

Help with GCC and ObjectiveC code and Cygwin

Is it possible to build objective c code correctly with GCC under cygwin. I have the following application that should work on a Mac environment, but can't get the most basic stuff to work with gcc. Are there more libraries I need to have. #import "HelloWorldApp.h" int main(int argc, char *argv[]) { return 0; } // End of the //...

How to code a method, function or variable in Objective - C

I have just started to learn Objective - C. I have done one year of Java programming and one year of Actionscript. I need to find a website or blog which tells me how to do the basic things for example declare a variable or how to write a method and function. I cant seem to find this anywhere. If someone could give me some good links tha...

Cocoa Check for Updates

What is the best way to add a "Check for updates..." functionality to a Cocoa application? I saw a little framework implementing this but I'm not sure that's the better way. Should I implement it from scratch? ...

Core Data and xcdatamodel files vs the generated files

Is it the generated files from the data model that matters more or is the actual xcdatamodel file? And is it possible to change the ownership property from 'retain' to 'copy' for the files that are autogenerated from the xcdatamodel class? ...

Adding CalTasks from an NSArray.

I have an NSArray of Strings and what I want to do is create a new CalTask (for the calendar store) for every String, I want the Name of the task to be the string that is being added, the Priority and Due Date to be set in the code. For example I have an array with the Strings To-Do 1, TD 2, TD 3. So I want to create 3 CalTasks, the fir...

Using NSScanner to identify characters in NSString

Hi, newbie here...I'd like take my input which is an NSString and use NSScanner to identify and act upon the characters typed. I've taken another example i've found and modified it however need more help. For example: NSString *yourString = @"Hello"; // For example NSScanner *scanner = [NSScanner scannerWithString:yourString]; NSChara...

CoreData add[ttt] vs set[ttt] - difference in to-many relationship?

With a one-to-many relationship: the generated classes from the xcdatamodel will have: @interface Department (CoreDataGeneratedAccessors) - (void)addEmployeeObject:(Employee *)value; - (void)removeEmployeeObject:(Employee *)value; - (void)addEmployees:(NSSet *)value; - (void)remove Employees:(NSSet *)value; @end Would 'addEmployees' r...

Cocoa menu with images

I need to make a popup or pull down menu in Cocoa that will contain either an image or an image with text as the representation of the item. Can anyone suggest a way I could do this programatically? ...

[iPhone SDK] What is the best way to store Text Messages? Something like SMS

Hi, I´m writing a small prgramm in which the User is able to send small Messages (460 Characters). Now I want something like a History in which the user can see all Messages he ever send from this App inlucing the recipient and the Text, both are Strings. Is Core Data "to much" for this? Any other Idea? Thank you twickl ...

for loop execution doesn't permit touches on iPhone.

Ok. I know the title may be confusing. Logic That I have implemented is something like this. There is an detector in application ( like bike speedometer - moving arrow ) When user taps start scan button - first method executes. NowStartMovements decides random rotations & random number to stop There are 1 to 10 numbers on detector. Ev...

Keep a reference to a file after it has moved in objective-c?

I have a Cocoa application that stores a reference to multimedia files (images, videos, etc) on the user's computer. I'm wondering if there is a way to get a reference to that file other that using a file path so that if the user moves that file to a different folder on their computer, I would still know where it is. I'm currently stor...

Landscape only View in Cocoa Touch

Is there to way to fix a view's orientation in a landscape position, regardless of the device's current position? To be more specific, I have a UIWebView in a UINavigationController that should always show its content as if the device were rotated 90 degress counterclockwise. I only want the web view to be restricted to this orientation...

Is NSDictionary's objectForKey look up reference or value based?

I have a NSMutableDictionary instance and the keys I'm using are NSNumber* type. In the scenario I have, I'm trying to use 'objectForKey' to retrieve an object in my dictionary that I know is present. But I keep getting nil for the result unless I make convert the key from NSNumber to NSString. NSNumber *itemId = [NSNumber numberWithIn...

Object / Class Confusion?

I noticed whilst playing around today that both the objects below when sent "init" print the same message "_init: TireSnow" to the console. Can anyone shed any light on why this is happening? // INTERFACE @interface TireBasic : NSObject { } @end @interface TireSnow : TireBasic { } @end // IMPLEMENT @implementation TireBasic - (id) init...

Must I retain the date from a UIDatePicker Modal View?

I'm getting crashes from my UIDatePicker view and I think it's because I'm not retaining the pickers selected date. Can anyone tell me if this could be correct? I have a modal view for selecting a toDate and a fromDate range. These values are passed into the modal view and grabbed out of the view when it's dismissed. The view has one UI...

Getting total number of enum items

Is it possible to get the total number of items defined by an enum at runtime? While it's pretty much the same question as this one, that question relates to C#, and as far as I can tell, the method provided there won't work in Objective-C. ...

Setting an image for a UIButton in code.

Hi, How do you set the image for a UIButton in code? I have this: UIButton *btnTwo = [UIButton buttonWithType:UIButtonTypeRoundedRect]; btnTwo.frame = CGRectMake(40, 140, 240, 30); [btnTwo setTitle:@"vc2:v1" forState:UIControlStateNormal]; [btnTwo addTarget:self action:@selector(goToOne) forControlEvents:UIControlEventTouchUpInside];...

Terminating Another App Running - Cocoa

Hey all, How can I terminate another app that is running in cooca. Let's say I have iTunes running, and I type in quit in my app, it would quit itunes. "iTunes" is just an example, it could be anything the user wants. I can open any app from my application, but I want to know how to close any app running. thanks kevin ...