Hi,
I have an NSString somewhat like this:
<some lines (unknown amount)>
Key1:thingIWantToKnow
Key2:otherThing
<more lines (also not known how much)>
All lines end with a newline (\n) character. Sometimes the string behind the Key#: is empty (@"") but I would still like to have it.
I was thinking of something like getting the start ...
I have a string
"AA - The Title of the Person"
How can I get the part before the '-'?
The output should be "AA"
Also if the input doesn't have a '-' then output should be nil
...
Hi, everyone,
I want to ask an NSString * question. I have a NSString * object. The content is like the following example. (like the CSV file)
Example: (my file is longer than this one so much)
First Name,Last Name,Middle Name,Phone,Chan,Tim,Man,123-456-789,Tom,,,987-654-321
(if it is empty, no space between the ',')
How can I use ...
Hi, everyone,
I want to ask an NSString * question. I have a NSString * object. The content is like the following example. (like the CSV file)
Example: (my file is longer than this one so much)
First Name,Last Name,Middle Name,Phone,Chan,Tim,Man,123-456-789,Tom,,,987-654-321
(if it is empty, no space between the ',')
How can I inse...
Hi, everyone,
I want to ask a question about the NSString * in objective C. Can I check the last char of a NSString * object?
Example:
NSString* data = @"abcde,";
if(data is end with ',') // I don't know this part
// do sth
Thank you very much.
...
Hi, everyone,
I want to ask a question about the NSString * in objective C. I have an string read from somewhere and I would like to get the last char of that NSString object? I used to try the objectAtIndex, but I don't know what to get the index. What should I type? Thank you very much.
...
Hi, everyone,
I want to compare 2 NSString *. I use the [[arr objectAtIndex: i]compare: @"compareString"] . However, it does not work in my program. What wrong of the problems?
...
Hi
I want to add string to message of my UIAlertView
-(void) errorState:(NSException *) exp
{
NSLog(@"Error State Blood Level3 %@",exp);
NSString * myString = (NSString*)exp;
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:myString delegate:self cancelButtonTitle:@"Go to the main menu" otherButton...
Hi,
I have to implement a small feature in an iPhone app and was wondering if there was a way to do use an if statement where the condition is the string of a button.
Here’s a sample of the code in question:
- (IBAction)someMethod:(id)sender{
UIButton *button = (UIButton *)sender;
if ( button.titleLabel.text == “SomeText” )
{
//...
If I have a method
- (void) myMethod:(NSString *)string {
[Object anothermethodWithString:string];
}
and I call
[Object myMethod:@"this is a string with no alloc statement"]
Do I need to do something like
- (void) myMethod:(NSString *)string {
NSString *string2 = [[NSString alloc] initWithFormat:@"%@", string];
[Object...
I have a CoreData NSManagedObject subclass, TextNarration, that has an attribute of type NSString, textURI. That class implements the NSCoding protocol methods: initWithCoder and encodeWithCoder this way:
- (id) initWithCoder: (NSCoder *)coder
{
if (self = [super init])
{
self.textURI = [coder decodeObjectForKey:@"te...
Does Cocoa provide a built-in method to convert a key string into a properly-formatted set property accessor? i.e. "lineSpacing" -> setLineSpacing:
For example:
NSString * key = @"lineSpacing";
SEL selector = [key magicallyConvertIntoSetPropertyAccessor];
or even:
NSString * key = @"lineSpacing";
SEL selector = NSSelectorFromString(...
Hi all, I'm trying to load a PDF in my App:
Using this works fine
pdfURL=[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource: @"myFile" ofType:@"pdf"]];
controller.pdfUrl = pdfURL;
[self.navigationController pushViewController:controller animated:YES];
[controller release];
Howev...
Hi all!
I have a question...
I wish take from a string that contains a name and surname, the initial of the first and the surname complete....
example:
NSString* myName = @"Mel Gibson";
//I Wish have "M Gibson";
NSString* myName2 = @"Leonardo Di Caprio";
//I wish have "L Di Caprio";
Thanks
...
I am using the following code to open a file's contents and save it to another file.
when it runs the original file length is 793 but the saved file is 0. I have also tried just to copy the file. Nothing seems to work.
Is there some kind of permissions I'm missing on the documents directory?
NSError *error;
NSString *basePath = [...
How can I detect if a string contains a certain word? For example, I have a string below which reads:
@"Here is my string."
I'd like to know if I can detect a word in the string, such as, "is" for example.
THank you in advance
...
Hi,
I want to generate unique file paths in Objective-C. I looked at NSTemporaryDirectory() but the closest I could get was to this and this. But in the second one they create such a file. I do not want to create it, I just want an NSString for a unique writable path... I don't need paths to folders, just files. How is this possible?
...
Hi guys, I have this very strange problem, I'm new to objective-c and it probably comes from depths which I don't comprehend yet.
So, in my header file I declare the variable
NSString *curTitle;
then in .m file I synthesize it:
curTitle = [[NSString alloc] init];
after that in other method I assign it:
curTitle = string; // strin...
I accept NSString as
NSString *value = [valuelist objectAtIndex:valuerow];
NSString *value2 = [valuelist2 objectAtIndex:valuerow2];
from UIPickerView.
I want to
double *cal = value + (value2 * 8) + 3;
NSString *message =[[NSString alloc] initWithFormat:@"%@",cal];
I should be able to get the string in message after I do the calc...
I have a very simple question. Is there a built in method to shorten strings? If not can someone provide an example of doing that in ObjC?
For example:
ThisIsAVeryLongString
should become
ThisIsAV...
It needs to check if the string is over a certain amount of characters and if it is shorten it.
...