When I tap on a certain position in a UITextView, I want to retrieve the substring of the NSString which is shown at the line.
I have e.g. a UITextView which displays a string, using 16 lines. When I tap on position (200, 150), I want the substring which is shown by UITextView on that tap.
Any suggestions on how to achieve this?
...
Is there any easy way to get the string index in an NSString if I have the line number and column number?
For example:
myString =
abc
def
ghi
[myString getIndexFromLineNumber:2 columnNumber:1] should return the index of h in myString, so in this example it should be 10 (assuming new lines are 1 char long).
...
Say I have a string:
NSString *state = @"California, CA";
Can someone please tell me how to extract the last two characters from this string (@"CA" in this example)
...
I am pulling data from a website via NSURLConnection and stashing the received data away in an instance of NSMutableData. In the connectionDidFinishLoading delegate method the data is convert into a string with a call to NSString's appropriate method:
NSString *result = [[NSString alloc] initWithData:data
...
How do I retrieve the project directory of an xcode project targeted for the ipad?
Or if it isn't possible, then how do it retrieve the home directory of the user?
something like:
NSString *path = [NSProject getPath];//could be absolute or relative
or
NSString *homeDir = [NSURL getUserDirectory];
...
I want to use NSRegularExpression in my iPhone app, but Apple's documentation says that it was first available in iOS 4. Since iPads are still running on iOS 3.2 this means that my app would not be available for iPads -- correct? Is there any way to get around this? Or do I just need to wait until apple's iOS 4.1 release which should sup...
Is there a list of the Unicode encoding hex of every Emoji character on iPhone? Thanks!
...
I am having an issue that I can't figure out.
I'm trying to run the rangeOfString method on a string, and I'm not sure how to determine if the string was not found. For example:
NSRange range = [@"abc" rangeOfString:@"d" options:NSCaseInsensitiveSearch range:NSMakeRange(0,3)];
Clearly, "d" is not contained in the string "abc." I'd li...
I'm using Core data and region monitoring. The only way to distinguish between monitored regions is with a NSString for identifier. I'd love to use NSManagedObjectID, but I can't get it to work.
What I've tried:
NSURL *objURL = [managedObjectID URIRepresentation];
NSError *err;
NSString *identifier = [NSString stringWithContentsOfURL:m...
Hi, everyone,
I want to ask a question about the objective C. Does the NSString * contains some functions to check the NSString * contains some string in the UITextField.text? For example
NSString *checkString = @"abcd%"
if(checkString contains '%') // I want this function
return YES;
else
return NO;
...
Hi, everyone,
I want to ask a objective C question. I have a string retrieve from UITextField and I want to check the string contains the '@' or not. However, when I use the following code, it has some errors, can anyone help me? Thank you.
if([inputTextField.text rangeOfString:@"%"].location != NSNotFound)
NSLog(@"It does not cont...
Hey All,
I know this is a silly doubt but I just want to make sure before I implement in this project. Please help....I have a NSDictionary with a string object in it. String is concatenated with 4fields. I am trying to display this string on the Detail View Controller in UITableView on iphone.
For example my String is formatted as foll...
For example, suppose I have an NSString @"20O(2H,1H)19O", and I want all the numbers to be superscript. Is there an easy way to do this?
...
I have a string in the form of
"11:00AM, Saturday August 21, 2010"
How do I convert this to an NSDate object?
...
I'm using Gamekit to send data via bluetooth between two devices. I want to get the name of the device that sent it, but if the name is "Bob's iPhone" I want to cut off the "'s iPhone". I first check for ending in "iPhone" or "iPod Touch".
if ([name hasSuffix:@" iPhone"])
{
name = [name substringToIndex:[name length]-7];
}
else i...
I'm trying to take an input string and return a new string that is encoded/decoded based on a dictionary that I created. I have tried the below code using instance variables and local variables. I am having a problem using the for loop. I get out of scope errors. When I use an instance variable for newText, I get a exec bad address w...
I'm running into a bit of a weird issue. Whenever I create a new text file in my iOS application, I set its encoding to be NSUTF8StringEncoding. If I edit the file and input any characters with diacritics and save the changes, the diacritics render properly in some applications such as BBEdit, TextMate, cat and vi but not in others suc...
Hi I have an array of strings separated with a delimeter ":". I tried separating strings using componentsSeparatedByString method and then save the result into an array and later use that array to produce the desired output, but it didn't worked.
For example
Now my UITableView displays cells as:
Case 1:
How:Many
Too:Many
Apple:Milk...
Is there a way to define a custom path of where the strings for NSLocalizedString are read from? I am aware you can define what filename to read from, but I am trying to make a user-editable system that will be stored in the Application Support folder. If there is no way to change the path it reads from, then is there a low-level class b...
Hi,
trying to figure out how to add zeroes in front of a random generated number with dynamic length of the number.
For example if the number is 10 characters long, I can print the number as stringWithFormat:@"%.10d",i
Since the numer can somtimes be shorter than maximum length, it needs zeroes to fill the maximum length of the numbe...