0

I seem to be having trouble with loading the id value which is displayed within my iphone application.

When I run the app, it loads the the name, price and a and an image URL. The only section which fails to load depending on its value is the id. Is anyone able to tell me why this happens just by looking at this code?

[NSString stringWithFormat:@"http://localhost/AM.php?id=%@",self.scannedValue]

When I change %@ to an integer value it shows the image and other info for that id number, but I'm trying to get that part of the code to take ANY id number.

localhost/AM.php?id=101 

localhost/AM.php?id=102  

localhost/AM.php?id=103 <<---- All of the ID's display data about a different item etc..

I set self scannedValue in my scannedViewController.m, I am basically using the zBar Scanner to scan a barcode and display the fields I mentioned above.

Can someone please tell me why i have trouble with the code displaying different id's? I already tried the format specifier %@ but it fails to work.

Code from my viewcontroller.m

- (void) readerView:(ZBarReaderView *)readerView didReadSymbols:(ZBarSymbolSet *)symbols    fromImage:(UIImage *)image {
for (ZBarSymbol *sym in symbols) {
    [reader stop];
    [reader removeFromSuperview];
    scannedValue = sym.data;
    [self performSegueWithIdentifier:@"showDetails" sender:self];
    break;
}

}

In this

scannedValue = sym.data; 

is string, sum is ZBarSymbol class object

In the ZBarSymbol class

@property (readonly, nonatomic) NSString *data; 

is the starting value.

When successfully scanned a value it will return a NSString *data in delegate method.

GoGreen
  • 2,251
  • 1
  • 17
  • 29
user3310055
  • 31
  • 1
  • 7
  • Is self.scannedValue a string or an integer? – Ken Toh Feb 24 '14 at 06:32
  • 1
    Add more code where you are having the problem dealing with the id. `self.scannedValue`, what type is it and what is the `NSLog`ed value? Show the declaration and setting code. – zaph Feb 24 '14 at 06:56
  • @kentoh are you able to see the edit? – user3310055 Feb 24 '14 at 09:59
  • @Zaph are you able to see the edit? – user3310055 Feb 24 '14 at 09:59
  • @user3310055 if you nslog scannedValue, what so u get? – Ken Toh Feb 24 '14 at 10:55
  • It displays the id number of the code which is scanned, but fails to go to the next view. It just stalls and goes into an error. – user3310055 Feb 24 '14 at 12:31
  • You have `scannedValue = sym.data` but `scannedValue` is not declared in the method. perhaps that should be: `self. scannedValue`. – zaph Feb 24 '14 at 12:54
  • Fix any compiler warnings. Run the Xcode Analyzer and fix any warnings/errors. – zaph Feb 24 '14 at 13:09
  • user3310055 asked you to `NSLog` the `scannedValue` but you did not provide the result. If you want help provide more complete answers and more complete example code. Some of the code posted would not even compile. – zaph Feb 24 '14 at 13:16

0 Answers0