Say I have my class
@interface Person : NSObject { NSString *name; }
I need to get the name of NSString's within my class
Person *person = [[Person alloc] init];
NSLog(@"Name of variable %s\n", _NameofVariable_(person->name));
Thanks for the answers, here's the solution I came up from the replies
//returns nil if property is no...
my UITableView have serious memory leak problem only when the NSString is NOT encoding with NSASCIIStringEncoding.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"cell";
UILabel *textLabel1;
UITableViewCell *cell = [tableView dequeu...
Hello,
my app crashes often in this for-loop:
for (int a = 0; a <= 20; a++) {
NSString * foo = [[NSString alloc]initWithString:[[newsStories objectAtIndex:arc4random() % [newsStories count]] objectForKey:@"title"]];
foo = [foo stringByReplacingOccurrencesOfString:@"’" withString:@""];
foo = [[foo componentsSepara...
I've got some somewhat hefty string size calculations happening in my app (each one takes close to 500ms, and happens when the user scrolls to a new "page" in my app (like the Weather app). The delay only happens once per page, as the calculation only needs to be run once (and can even be cached for subsequent launches with the same data...
I create NSMutableUrlRequest for sending data to server, add all necessary fields to it and then add the string for sending like this:
[theRequest setHTTPBody:[postString dataUsingEncoding: NSUTF8StringEncoding]];
postString is a usual NSString.
The problem is, when I receive this request at the server, all the plus (+) signs disappe...
Hi everyone,
I have a long NSString in which I m trying to replace special characters. Part of my string looks like this:
"veau (c\u00f4telette)","veau (filet)","agneau (gigot)","agneau (c\u00f4telette)","b*\u0153*uf (hach\u00e9)","porc (hach\u00e9)"
I would like to replace all the \u0153 with "oe". I ve tried:
[response stringByRepla...
Hello,
I have a String with this content:
href="http://www.website.com/" /> [...] [...]
I just want to get the central part of the string. How is it possible to get the part between @"href="" and @"" />"
Note: Even if it looks like xml-code, it is inside of a NSString.
...
Isn't there any method in Objective-c that converts a hex string to bytes? For example @"1156FFCD3430AA22" to an unsigned char array {0x11, 0x56, 0xFF, ...}.
...
How do you check if an NSString begins with a certain character (the character *).
The * is an indicator for the type of the cell, so I need the contents of this NSString without the *, but need to know if the * exists.
...
hello,
how to append the value of string in between NSString?
for example:
NSString* str1 = @"Hello";
NSString* str2 = @"Hi.."/*add contents of str1*/@"how r u??";
please tell me how to achieve this??
...
I am trying to get 10 mp3 files in the resources folder and play them when a button is pressed. I have entered name of the mp3 files in a NSMutableArray and read each one after the button is pressed.
The problem is that pathForResource: is not working (returns nil). If i use the file name explicitly -like pathFoResource:@"song1.mp3" ofT...
NSString *myString = @"sample string";
NSString *newString = [myString copy];
If I set a breakpoint after these two lines, the pointer for myString is the same as the pointer for newString.
WTF? Isn't NSString copy supposed to return a pointer to a new object? Or am I missing something fundamental about how copy is supposed to w...
Is it possible to get the first line of text from a UITextView. I have looked through the UITextView and NSString Class References and can't find any methods that could accomplish this.
...
I have an NSString that will be something like "xxxx (yyyyy)" where x and y can be any character. I'd like to extract just the y from inside the parenthesis. I managed to extract the x using a NSScanner but I haven't figured out the proper way to extract out the y.
...
Basically I want to copy the behavior in iPhone's Calendar where the day of week (Mon, Tue, Wed) is on the left side of the table's section header (left justified) while the formatted date (Apr 1, 2010, May 1, 2010) based on locale is on the right side of the table's section header (right justified).
I was thinking of inserting a variab...
I'm running into a problem with a string that contains encoded characters. Specifically, if the string has encoded characters it eventually becomes invalid while a "normal" string will not.
in the .h file:
@interface DirViewController : TTThumbsViewController
<UIActionSheetDelegate,UINavigationControllerDelegate,UIImagePickerControlle...
cipher.h cipher.m are developing a module has.
NSData value of the encrypted value problem as follows. : <0b21kck 0v35919 sk2910>
As the purpose of encryption is to be sent to NSURLConnection String value.
NSString value to NSData encrypted so I think it must be converted to
What can you do?
...
When I store a NSString inside some NSDictionary and log that dictionary to the console like this:
NSString *someString = @"Münster";
NSDictionary *someDict = [ NSDictionary dictionaryWithObjectsAndKeys:
someString, @"thestring" ];
NSLog ( @"someDict: %@", [ someDict description ] );
The console output looks like this:
unico...
I am trying to set some text on a label
descriptionLabel.text = [NSString stringWithFormat:mySTUser.bio];
The bio property of mySTUser is an NSString. Sometimes it is not an NSString when I set it. How can I check if mySTUser.bio is an NSString so I can prevent it from being assigned to my label text?
...
*cipher.h, cipher.m all code : http://watchitlater.com/blog/2010/02/java-and-iphone-aes-interoperability
Cipher.m
-(NSData *)encrypt:(NSData *)plainText{
return [self transform:KCCEncrypt data:plainText;
}
step1.
Cipher *cipher = [[Cipher alloc]initWithKey:@"1234567890"];
NSData *input = [@"kevin" dataUsingEncoding:NSUTF8StringEnc...