68
votes
3answers
57k views

AES Encryption for an NSString on the iPhone

Can anybody point me in the right direction to be able to encrypt a string, returning another string with the encrypted data? (I've been trying with AES256 encryption.) I want to write a method which ...
217
votes
10answers
158k views

How to convert an NSString into an NSNumber

How can I convert a NSString containing a number of any primitive data type (e.g. int, float, char, unsigned int, etc.)? The problem is, I don't know which number type the string will contain at ...
84
votes
10answers
83k views

Objective-C: Reading a file line by line

What is the appropriate way of dealing with large text files in Objective-C? Let's say I need to read each line separately and want to treat each line as an NSString. What is the most efficient way of ...
43
votes
6answers
35k views

Converting NSString to NSDate (and back again)

How would I convert an NSString like "01/02/10" (meaning 1st February 2010) into an NSDate? And how could I turn the NSDate back into a string?
27
votes
5answers
24k views

Understanding NSString comparison

Both the following comparisons evaluate to true: 1) @"foo" == @"foo"; 2) NSString *myString1 = @"foo"; NSString *myString2 = @"foo"; myString1 == myString2; However, there are definitely times ...
49
votes
12answers
20k views

Remove all but numbers from NSString

I have an NSString (phone number) with some parenthesis and hyphens as some phone numbers are formatted. How would I remove all characters except numbers from the string?
44
votes
14answers
45k views

iPhone how to check that a string is numeric only

How do I validate the string input from a UITextField? I want to check that the string is numeric, including decimal points.
22
votes
2answers
19k views

Converting a string to an NSDate

How is it possible to convert a string to an NSDate on iOS?
9
votes
5answers
22k views

Comparing Strings in Cocoa

I have tried: - (NSString*) generateString { NSString* stringToReturn = @"thisString"; return stringToReturn; } - (void) otherMethod { NSString *returnedString = [self generateString]; ...
29
votes
7answers
16k views

Objective-C url encoding

I have a NSString like this: http://www. but I want to transform it to: http%3A%2F%2Fwww. How can I do? thanks
16
votes
11answers
20k views

Number of occurrences of a substring in an NSString?

How can I get the number of times an NSString (for example, @"cake") appears in a larger NSString (for example, @"Cheesecake, apple cake, and cherry pie")? I need to do this on a lot of strings, so ...
82
votes
12answers
49k views

Collapse sequences of white space into a single character

Consider the following example: " Hello this is a long string! " I want to convert that to: "Hello this is a long string!"
11
votes
5answers
1k views

Difference between NSString literals

What is the difference between these two lines? NSString * string = @"My String"; NSString * string = [[[NSString alloc] initWithString:@"MyString"] autorelease]
4
votes
2answers
3k views

How to make subscripts and superscripts using NSAttributedString?

I need to make subscripts for chemistry formulas (H2O, Na^2+, etc)? Is this possible to do with NSAttributedString, or is there an alternative/easier way to make subscripts?
15
votes
3answers
6k views

What is the maximum length of an NSString object?

What is the maximum sized string that can be held in a NSString object? Does this change dynamically?

15 30 50 per page