Based on this SO question asked a few hours ago, I have decided to implement a swizzled method that will allow me to take a formatted NSString as the format arg into stringWithFormat, and have it not break when omitting one of the numbered arg references (%1$@, %2$@)
I have it working, but this is the first copy, and seeing as this meth...
I have some sample code from Tuaw which is probably 3 releases old ;) The compiler is issuing a warning that the method is deprecated, but I do not see that mentioned in the SDK docs. If it is deprecated, there must be an alternative approach or replacement method. Does anyone know what the replacement is for this method?
The specifi...
I have a NSArray of CalEvents returned with the [CalCalendarStore eventPredicateWithStartDate] method. From the events returned, I am trying to keep only those in which the title of the event == @"on call" (case-insensitive).
I am able to keep in the array those events whose title includes @"on call" with the following code (where event...
Hello.
I'm developing an iPhone application.
I use a NSDictionary to store city's names as key, and population as value. I want to search the keys using lowercase.
I've using this:
NSDictionary *dict;
[dict objectForKey:[[city stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] lowercaseString]];
But...
I'm puzzled... I have this function "colorWithHexString"... when I include it in the viewcontroller that's calling it then it works fine. But when I move it to a separate "BSJax" class and call it with the same input parameter it throws an unrecognized selector error. Here's the call:
BSjax *bsjax = [BSjax new];
NSString *hexString = ...
Hi, Please give me some suggestions about how to change a NSString variable.
At my class, I set a member var:
NSString *m_movieName;
...
@property(nonatomic, retain) NSString *m_movieName;
At viewDidLoad method, I assign a default name to this var:
-(void)viewDidLoad{
NSString *s1 = [[NSString alloc] initWithFormat:@"Forrest Gump"]...
How can I cast a NSString* into a char?
EDIT:
Thanks to Vladimir for getting me there!
NSString *myString = @"HelloWorld";
const char *stringAsChar = [myString cStringUsingEncoding:[NSString defaultCStringEncoding]];
Hope this helps someone in the future!
...
Hi,
I have a problem with creation to NSString.
The error is: "error: expected ']' before numeric constant".
The code is below.
Can you help me to find a solution for create these?
NSString *titleXML = [NSString stringWithFormat:@"<?xml version="1.0" encoding="UTF-8"?>"];
...
Hi,
i have a NSString instance ,i want to retrieve value from it and store it into an integer.
This is wat i am doing but its not working.
NSString *totalcnt;
char *str = totalcnt;
int a = atoi(str);
Help me out.
Thanks
Taimur
...
Hi,
I have an NSString in an NSObject file, I inherited this NSString into my MainViewController where it gets the value.
Now, I want to use this NSString value in another UIViewController subclass.
From some reason I always get (null)
Here's my code:
MainViewController:
leftWebViewUrl = [NSMutableString stringWithString:leftWebVi...
I have an array of NSStrings:
Flower
Car
Tree
Cat
Shoe
Some of these strings have images associated with them; some don't. I can build an image name by appending .png to the name (e.g. Flower.png).
How do I check whether that image actually exists within the bundle before I try to load it into the view?
...
Hi all,
i have a little question ,i have a NSString object
(\n "1 Infinite Loop",\n "Cupertino, CA 95014",\n USA\n)
and i want the substring present within 2nd double quote and first comma of 2nd double quote (Ex.Cupertino) from this string.(Note: My string is Dynamic)
Till now i have used stringByReplacingOccurrencesOfString: and abl...
I want to read a file, line by line and then assign to each line a variable.
I have the following code:
NSString *aFilePath= [[NSString alloc] initWithContentsOfFile:@"db.def"];
NSArray *lines = [aFilePath componentsSeparatedByCharactersInSet:[NSCharacterSet newlineCharacterSet]];
char *server = [[lines objectAtIndex:0] UTF8Str...
Could someone please tell me if I am missing something here... I am trying to parse individual JSON objects out of a data stream. The data stream is buffered in a regular NSString, and the individual JSON objects are delineated by a EOL marker.
if([dataBuffer rangeOfString:@"\n"].location != NSNotFound) {
NSString *tmp = [dataBuffer ...
Hi, I have this call to stringwithcontentsofurl:
[NSString stringWithContentsOfURL:url usedEncoding:nil error:nil];
How can I give that a simple timeout?
I don't want to use threads or operation queues (the content of the url is about 100 characters), I just don't want to wait too long when the connection is slow.
...
I have some NSString varibales that incude items like
Ð and Õ and if I do
cell.textLabel.text = person.name;
and if it contains one of those characters the cell.textlabel is blank!
I have discovered that if I use
NSString *col1 = [NSString stringWithUTF8String:(char *)sqlite3_column_text(compiledStatement, 0)];
To pull my data b...
I'm some trouble adding strings together for a UITextView in my app. The method I've been using is this
(header)
#import <UIKit/UIKit.h>
@interface calculatorViewController : UIViewController {
IBOutlet UITextView *output;
}
-(IBAction)b1;
@property(nonatomic, copy) NSString *output;
@end
(main)
#import "calculatorViewCont...
Hi,
i am working with web services these days ,and with all xml files that i am parsing things are fine ,but with the last one the famous method "stringWithContentsOfURL" returns empty data. Why?
...
Hi Guys,
I getting the leak in this method even the allocated nsstring is released.
Now I am taken stringWithFormat, but still it is showing the leak at "NSData *returnData=...." line
-(BOOL)getTicket:(NSString*)userName passWord:(NSString*)aPassword isLogin:(BOOL)isLogin
{
NSString* str=@"";
if (isLogin == YES)
{
str =[NSString strin...
Hi,
I have an UIViewController named MainViewController
I have another UIViewController named LeftSharingViewController;
I would like to get and use the NSString from MainViewController in my LeftSharingViewController
I have a problem, I always get (null) instead of the NSString wanted value.
Here's my code and how does the NSString ...