Search Results

Search found 605 results on 25 pages for 'stringwithformat'.

Page 14/25 | < Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >

  • Facebook writing on a wall problem - retrieves only null value.

    - by Viral
    hi all friends, I am making a game application in that I want to pass my score on wall of face book. I've completed all the things (the log in and message passing part) but when I passes the score via global variable, I am getting only null as a value and not the score that I want. Is there any way to pass data or string to Face book and write on a wall? My code is (void)viewDidLoad { static NSString* kApiKey = @"be60415be308e2b44c0ac1db83fe486b"; static NSString* kApiSecret = @"4f880c7e100321f808c41b1d3c813dfa"; _session = [[FBSession sessionForApplication:kApiKey secret:kApiSecret delegate:self] retain]; score = [NSString stringWithFormat:@"%@",appDelegate.myTextView]; [_session resume]; [super viewDidLoad]; } whre score is NSString and myTextView is NSString in other viewcontrollerfile, And appDelegate is global variable. Any help?? thanks in advance.

    Read the article

  • Log the method name in objective-C?

    - by vodkhang
    Currently, we are defining ourselves an extended log mechanism to print out the class name and the source line number of the log. #define NCLog(s, ...) NSLog(@"<%@:%d> %@", [[NSString stringWithUTF8String:__FILE__] lastPathComponent], \ __LINE__, [NSString stringWithFormat:(s), ##__VA_ARGS__]) For example, when I call NCLog(@"Hello world"); The output will be: Hello world Now I also want to log out the method name like: Hello world So, this would make our debugging become easier when we can know which method is getting called. I know that we also have XCode debugger but sometimes, I also want to do debugging by logging out.

    Read the article

  • UIScrollView: Is 806k Image too much too handle? (Crash, out of memory)?

    - by Jordan
    I'm loading a 2400x1845 png image into a scroll view. The program crashes out of memory, is there a better way to handle this? mapScrollView is an UIScrollView in IB, along with a couple of UIButtons. -(void)loadMapWithName:(NSString *)mapName { NSString* bundlePath = [[NSBundle mainBundle] bundlePath]; UIImage *image = [UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"%@/path/%@", bundlePath, [maps objectForKey:mapName]]]; UIImageView *imageView = [[UIImageView alloc] initWithImage:image]; CGSize imgSize = image.size; mapScrollView.contentSize = imgSize; [mapScrollView addSubview:imageView]; [imageView release]; [self.view addSubview:mapScrollView]; }

    Read the article

  • WebKitErrorDomain error 101

    - by Nam Young-jun
    The following code produces and error of: WebKitErrorDomain error 101 code: -(Void) searchBarSearchButtonClicked: (UISearchBar *) activeSearchBar { NSString * query = [searchBar.text stringByReplacingOccurrencesOfString: @ "" withString: @ "+"]; NSURL * url = [NSURL URLWithString: [NSString stringWithFormat: @ "http://http://www.google.com/search?q =%, query]]; NSURLRequest * requestObj = [NSURLRequest requestWithURL: url]; [Home loadRequest: requestObj]; } -(Void) loadView { [Super loadView]; CGRect bounds = [[UIScreen mainScreen] applicationFrame]; searchBar = [[UISearchBar alloc] initWithFrame: CGRectMake (0.0, 0.0, bounds.size.width, 48.0)]; searchBar.delegate = self; [Self.view addSubview: searchBar]; } I don't speak english and rely on a translator. Because of the language issue could this be a keyboard problem, or an encoding problem?

    Read the article

  • Can I update an iOS Enterprise App in the background like an App Store app can?

    - by lehn0058
    I have an iOS enterprise app that we are wirelessly distributing to our devices. Currently the app polls our server once a day to see if there is an app update. If there is, we try to install it by having the app call the following code: NSURL *installUrl = [NSURL URLWithString:[NSString stringWithFormat:@"itms-services://?action=download-manifest&url=%@", plistUrl]]; [[UIApplication sharedApplication] openURL:installUrl]; This causes the app to prompt the user with an alert dialog to install the update. If they click install, the app closes and the update is downloaded and installed. I am wondering if there is anything for enterprise apps for iOS 7 similar to the AppStore's automatic updates? I would like to be able to update our app without the user having to press an update button and be able to update at a time when the user won't have to wait for it to install.

    Read the article

  • sizeToFit label voids align right / set minimum width of label

    - by Deco
    Here is my code I am using to make a label (which contains content of an unknown length) the correct height for the content. (lines is equal to 0) myLabel.text =[NSString stringWithFormat:@"%@", myLabelContent]; myLabel.frame = CGRectMake(myLabel.frame.origin.x, myLabel.frame.origin.y, myLabel.frame.size.width, 800); [myLabel sizeToFit]; The only problem is, it is resizing the width as well as the height. I have two labels side by side, one aligned left, one aligned right. The left aligned one works fine. However, the right aligned one becomes intended (from the right). Because of its width resize, the content always starts at the origin.x position (in effect) because the label is made to be the shortest width required. I hope that makes sense. Is there a way to override or reset the width after auto resize had solved the height problem, or set a minimum width for the label? Many Thanks in advance, Deco

    Read the article

  • Objective-c Method to get a number then countdown in 1 every second

    - by Sami
    Hi, i need a little help i have a method which gets value such as 50, it then assigns that value to trackDuration, so NSNumber *trackDuration = 50, i want the method to every second minus 1 from the value of trackDuration and update a label, the label being called duration. Here's what i have so far; - (void) countDown { iTunesApplication *iTunes = [SBApplication applicationWithBundleIdentifier:@"com.apple.iTunes"]; NSNumber *trackDuration = [NSNumber numberWithDouble:[[iTunes currentTrack] duration]]; while (trackDuration > 0) { trackDuration - 1; int inputSeconds = [trackDuration intValue]; int hours = inputSeconds / 3600; int minutes = ( inputSeconds - hours * 3600 ) / 60; int seconds = inputSeconds - hours * 3600 - minutes * 60; NSString *trackDurationString = [NSString stringWithFormat:@"%.2d:%.2d:%.2d", hours, minutes, seconds]; [duration setStringValue:trackDurationString]; sleep(1); }} Any help would be much appreciated, thanks in advanced, Sami.

    Read the article

  • How to Invoke iPhone Maps for Directions with Current Location as Start Address

    - by eriaac
    Hi all. I know it's possible to start the iPhone maps application by calling openURL on a google maps URL with parameters saddr and daddr with location strings or LatLong (see ex. below), but I'm wondering if it's possible to make the start address be the "Current Location" maps bookmark so that I can use the maps app's location handling code. My Google search has been pretty fruitless. ex: [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat: @"http://maps.google.com/maps?saddr=%@&daddr=%@", myLatLong, latlong]]]; Except with something to invoke the current location bookmark in place of myLatLong. Thanks!

    Read the article

  • [Cocoa] NSImage transparency

    - by ndg
    I'm trying to set a custom drag icon for use in an NSTableView. Everything seems to work but I've run into a problem due to my inexperience with Quartz. - (NSImage *)dragImageForRowsWithIndexes:(NSIndexSet *)dragRows tableColumns:(NSArray *)tableColumns event:(NSEvent *)dragEvent offset:(NSPointPointer)dragImageOffset { NSImage *dragImage = [NSImage imageNamed:@"icon.png"]; NSString *count = [NSString stringWithFormat:@"%d", [dragRows count]]; [dragImage lockFocus]; [dragImage compositeToPoint:NSZeroPoint fromRect:NSZeroRect operation:NSCompositeSourceOver fraction:0.5]; [count drawAtPoint:NSZeroPoint withAttributes:nil]; [dragImage unlockFocus]; return dragImage; } Essentially what I'm looking to do is render my icon.png file with 50% opacity along with an NSString which shows the number of rows currently being dragged. The issue I'm seeing is that my NSString renders with a low opacity, but not my icon.

    Read the article

  • How to get arc4Sin() output into label/NSString

    - by Moshe
    I'm trying to take the output of arc4sin and put it into a label. (EDIT: You can ignore this and just post sample code, if this is too irrelevant.) I've tried: // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. - (void)viewDidLoad { [super viewDidLoad]; NSString *number = [[NSString alloc] stringWithFormat: @"%@", arc4random() % 9]; label.text = number; } I've created an IBOutlet for "label" and connected it. What's wrong here?

    Read the article

  • Selecting random numbers iphone sdk

    - by harekam_taj
    Hey, I want to select 10 random numbers from 1 to 35. I am trying to do the following, but I get some repeated numbers int totalNumberCnt = 1; while (totalNumberCnt < 11) { int randomNumber1 = 1 + arc4random() % 35; NSString *numberString = [NSString stringWithFormat: @"%d",randomNumber1]; NSLog(numberString); [firstNumber addObject:numberString]; [secondNumber addObject:numberString]; totalNumberCnt++; } Thank you for your help.

    Read the article

  • Require Integer Value not Memory Address whilst avoiding Invalid receiver type compiler warning

    - by Dave Anderson
    I have the following code; int days = [[SettingsUtils daysToRetainHistory] intValue]; [retainHistory setText:[NSString stringWithFormat:@"Days to retain History: %d", days]]; [daysToRetainHistory setValue:days animated:NO]; where [SettingsUtils daysToRetainHistory] is as follows; + (int) daysToRetainHistory { return (int)[[NSUserDefaults standardUserDefaults] objectForKey:@"CaseBaseDaysToRetainHistory"]; } I get the compiler warning Invalid receiver type 'int' because I call intValue on an int but unless I do this I can't seem to get the integer value out and always end up with the memory address i.e. 98765432 instead of 9 which ruins the UILabel display [retainHistory] and the UISlider [daysToRetainHistory] value. How do I avoid the compiler warning and still get my integer value in the label and the necessary float value for setting the UISlider value?

    Read the article

  • Objective-c class initializer executes multiple times

    - by apisip
    Unless I misunderstood it, this LINK from Apple's documentation clearly states that the class initializer, "+ (void)initialize)", only executes once per class. Here is the excerpt: Special Considerations initialize it is invoked only once per class. If you want to perform independent initialization for the class and for categories of the class, you should implement load methods. However, I'm getting a weird behavior on my project and the initializer is being executed twice. So I have to check if _classContext is null. I only got one class that has this method. What are the possible reasons why this is happening? I'm using XCode 4.5.2 and OS X 10.8.2. I got multiple iOS simulators, iPhone 5.1 and 6.0. + (void) initialize { num++; NSLog([NSString stringWithFormat:@"Times: %i", num]); if(_classContext == nil) _classContext = [[myClass alloc] init]; }

    Read the article

  • Updating the getDistanceFrom between two annotations in MapKit

    - by Krismutt
    Hey everybody! I wanna have a UILabel that shows the distance between two annotations... but how do I get it to update the distance each time the current location is updated (location)?? CLLocationCoordinate2 savedPlace = savedPosition; CLLocationCoordinate2D currentPlace = location; CLLocation *locCurrent = [[CLLocation alloc] initWithLatitude:currentPlace.latitude longitude:currentPlace.longitude]; CLLocation *locSaved = [[CLLocation alloc] initWithLatitude:savedPlace.latitude longitude:savedPlace.longitude]; CLLocationDistance distance = [locSaved distanceFromLocation:locCurrent]; [showDistance setText:[NSString stringWithFormat:@"%g", distance]]; Thanks in advance!

    Read the article

  • Is there a memory leak here?

    - by TheLearner
    Please see my comments in code: -(id)initWithCoordinate:(CLLocationCoordinate2D)c title:(NSString *)t { [super init]; coordinate = c; NSDate *today = [NSDate date]; NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateStyle:NSDateFormatterLongStyle]; NSString* formattedDate = [NSString stringWithFormat:@"%@ %@", [dateFormatter stringFromDate:today], t]; [self setTitle:formattedDate]; //Why does the app crash when I try and release formattedDate? I have after all passed its reference to the title property? [dateFormatter release]; //I need to release the dateformatter because I have finished using it and I have not passed on a reference to it return self; }

    Read the article

  • iOS - playing a youtube video from a webview thumbnail

    - by soleil
    Was about to finally submit an app when I realized that the youtube videos I'm playing play from the iPhone, but not the iPad. Here's the code I'm using: NSString *embedHTML = @"\ <html><head>\ <style type=\"text/css\">\ body {\ background-color: transparent;\ color: white;\ }\ </style>\ </head><body style=\"margin:0\">\ <embed id=\"yt\" src=\"%@\" type=\"application/x-shockwave-flash\" \ width=\"%0.0f\" height=\"%0.0f\"></embed>\ </body></html>"; NSString *html = [NSString stringWithFormat:embedHTML, [videoItem objectForKey:@"URL"], thumb.frame.size.width, thumb.frame.size.height]; UIWebView *videoView = [[UIWebView alloc] initWithFrame:thumb.frame]; [videoView loadHTMLString:html baseURL:nil]; [videoContainer addSubview:videoView]; Is there any reason this would work on the iPhone and not the iPad? I'm testing on a 1st generation iPad. The videos play on both iPhone models I've tested (3GS and 4S). Nothing happens at all when I tap on the webviews on the iPad.

    Read the article

  • I want to use contents of String or Array in an IF ELSE statement for iphone

    - by Michael Robinson
    I want to check to see if an array is empty to activate a shipping method. Here is the code for returning the array. NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *fullFileName = [NSString stringWithFormat:@"%@/arraySaveFile", documentsDirectory]; NSMutableArray *array = [[NSMutableArray alloc] initWithContentsOfFile:fullFileName]; I want to write something like: if NSString *fullFileName ="" ; [nnNEP EnableShipping]; else [nnNEP DisableShipping]; OR if array contents ="" ; [nnNEP EnableShipping]; else [nnNEP DisableShipping]; I just can't find the right or description on how to do this properly. Thanks,

    Read the article

  • Core Data fetch request with array

    - by JK
    I am trying to set a fetch request with a predicate to obtain records in the store whose identifiers attribute match an array of identifiers specified in the predicate e.g. NSString *predicateString = [NSString stringWithFormat:@"identifier IN %@", employeeIDsArray]; The employeeIDsArray contains a number of NSNumber objects that match IDs in the store. However, I get an error "Unable to parse the format string". This type of predicate works if it is used for filtering an array, but as mentioned, fails for a core data fetch. How should I set the predicate please?

    Read the article

  • NSDateFormatter iOS6 issue

    - by Angad Manchanda
    I have written a code for UIButton press to decrement date. The present date is shown in a UILabel text property and it changes to the previous date when the button is pressed. The following code works perfectly fine for iOS5 but doesn't work with iOS6. With iOS6, it gives the output as Dec 31, 1999 or null. - (IBAction)showPrevDate:(id)sender { NSString *dateForDecrement = _showDateLbl.text; [dateFormatter setDateFormat:@"MMM d, yyyy (EEE)"]; NSDate *dateObjectForDecrement = [dateFormatter dateFromString:dateForDecrement]; int subtractDays = 1; dateAfterDecrement=[dateObjectForDecrement dateByAddingTimeInterval:-(24*60*60 * subtractDays)]; _showDateLbl.text = [NSString stringWithFormat:@"%@", [dateFormatter stringFromDate:dateAfterDecrement]]; } Can anybody verify this, or tell me if its's a bug in iOS6 ? Thanks guys.

    Read the article

  • how to get a particular day of week in objective c??

    - by hemant
    using gregorian calender i am able to get the number of day of the week i.e 1 for sunday and 2 for monday etc but i am not able to find a function that displays the name of week then the number?? can anyone help?? here is my code to get the number of day NSDate *dates = [gregorian dateFromComponents:component]; NSDateComponents *weekdayComponents =[gregorian components:(NSDayCalendarUnit | NSWeekdayCalendarUnit) fromDate:dates]; NSUInteger *weekdays = [weekdayComponents weekday]; NSString *dayw=[NSString stringWithFormat:@"%1i",weekdays]; NSLog(@"%@",dayw);

    Read the article

  • [iPhone app] Inserting special char un NSString for URL use

    - by Dough
    Hi, I'm using HTTP connection to share data with my JSON server. I use URLs like "MyServlet?param1=value1" and so on... I'm now facing a problem with one of my servlet (I can't change it because some other views are using it) : The servlet is working with a syntax including those symbols "{" and "}". The exact syntax is {(value1_value2)(value3_value4)(value5_value6)}{(value7_value8)(value9_value10)(value11_value12)}{(value13_value14)(value15_value16)(value17_value18)} Values are integers, the problem is only when I use "{" and "}" my UrlConnection returns an error for bad URL. I use this to instantiate my NSString : NSString *myURL = [NSString stringWithFormat:@"http://somesite.com/Servlet?PARAM={(%@)}"]; How can I code those char in my NSString ? Thanks in advance !

    Read the article

  • Trying to trigger php script, get EXC_BAD_ACCESS iPhone development

    - by Brennan Kastner
    This below is my code, when it gets to the end of the function, the debugger throws an EXC_BAD_ACCESS error and when I check the website's logs, the url was never visited. If anyone could help me fix this issue, it would be greatly appreciated: -(IBAction)submitEmail:(id)sender { NSString *urlStringRaw = [[NSString alloc] init]; urlStringRaw = [NSString stringWithFormat:@"http://vedev.org/AnonMail/sendEmail.php?from=%@&to=%@&subject=%@&body=%@", from.text, to.text, subject.text, bodyContent.text]; NSString *urlString = [urlStringRaw stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; [urlStringRaw release]; NSURL * url = [NSURL URLWithString:urlString]; [urlString release]; NSURLRequest *requestObj = [NSURLRequest requestWithURL:url]; [url release]; NSURLConnection *connection = [NSURLConnection connectionWithRequest:requestObj delegate:nil]; [connection release]; [requestObj release]; }

    Read the article

  • Load image from server on a UIImageView in phone

    - by Pedro Narvaez
    Hi.. I'm having a problem loading a remote image into a UIImageVIew... It just doesn't show the image, may be i'm missing something... I also use the described here but with the same results How to load image from remote server on the UIImageView in iphone? Can someone help me? This is the code i'm using Im getting the data from a xml and on the image element I have the full path [[detailViewController detailImage] setImage:[UIImage imageWithData: [NSData dataWithContentsOfURL: [NSURL URLWithString: [NSString stringWithFormat:@"%@", [[promoList objectAtIndex: promoIndex] objectForKey: @"image"]] ]]] ]; With this code the image are displayed correctly [[detailViewController detailImage] setImage:[UIImage imageWithData: [NSData dataWithContentsOfURL: [NSURL URLWithString: @"http://localhost/promos/preview/1.jpeg"]] ]];

    Read the article

  • Word on HTML document point.

    - by leolobato
    Hey guys, How can I figure out which word is at the point where the user tapped on a UIWebView? I am able to detect the CGPoint for the tap (subclassing UIWindow like this), and I can actually get the DOM element on that point using javascript. But I know very little of javascript and DOM to figure out how can I actually get which word the user tapped on. Is that possible? Here's what I have right now: int scrollPosition = [[webView stringByEvaluatingJavaScriptFromString:@"window.pageYOffset"] intValue]; NSString *js = [NSString stringWithFormat:@"document.elementFromPoint(%f, %f).tagName", point.x, point.y+scrollPosition]; NSString *value = [webView stringByEvaluatingJavaScriptFromString:js]; NSLog(@"element: %@", value);

    Read the article

  • Dynamic name of NSMutableDictionary?

    - by Bruno
    Hi everyone I load from a txt file many info, and I would like, if possible, to dynamically create NSmutable dictionary with the elements of the txt. For example, each is like that: id of element | date | text What I'm asking is the equivalent of the NSString stringWithFormat:. Can we do the same for an Mutable Dictionary? To be more practical, let's say the NSString *date is equal to "23/12/2009" (for europe). I want to create a dictionary called 23/12/2009 without declaring *23/12/2009 but just something like dictionaryWithFormat: @"%@", date]; I'm stuck on this, and I don't even know if it is possible. If not, what's the best way to approach that? Thanks everyone Regards

    Read the article

< Previous Page | 10 11 12 13 14 15 16 17 18 19 20 21  | Next Page >