Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

IDMah

macrumors 6502
Original poster
May 13, 2011
316
11
Is there any chance that php/mysql/Json is messing up my string compare.

Using this:

Code:
 if ([iuuDee isEqualToString:myShareSingHS.uuidStringThing]) {
                   NSLog(@"Dude you have been BANNED");
                   // flag a message to be show //
                   // also add an option to do not display again flag // 
                   // remind me later // 
               }

when I print it they look the same..
Any ideas.

thanks
Ian
 

chown33

Moderator
Staff member
Aug 9, 2009
10,739
8,415
A sea of green
General development principle: Break It Down.

General debugging principle: Inspect the Details.


What is the length of each string?

What are the hex values of the characters (unichar) that make up each string? (Use the method characterAtIndex:)

Write test code that displays data that answers the above questions.
Then post the code, and the data it outputs.
 

IDMah

macrumors 6502
Original poster
May 13, 2011
316
11
talking to myself to help others..

Your Error was in the code before where you test for a null string.
so nothing got triggered. as a *Note nil and Null are not the same thing.

You need to test for the <NULL> first.

Code:
 // was if (!uuDee) which basically a stupid mistake and if (uuDee) crashed 
 //  because you can't compare a NULL string to a string 
 //  so ... do this // 
 if ( ![iuuDee  isKindOfClass:[NSNull class]]){
               if ([iuuDee isEqualToString:myShareSingHS.uuidStringThing]) {
                   NSLog(@"Dude you have been BANNED");
                   // flag a message to be show //
                   // also add an option to do not display again flag // 
                   // remind me later // 
               }
           }

Now everything works fine.. also changed the MySQL type to BLOB.

Hope this helps.
 

Sonnestah

macrumors regular
Mar 2, 2013
152
0
Your Error was in the code before where you test for a null string.
so nothing got triggered. as a *Note nil and Null are not the same thing.

You need to test for the <NULL> first.

Code:
 // was if (!uuDee) which basically a stupid mistake and if (uuDee) crashed 
 //  because you can't compare a NULL string to a string 
 //  so ... do this // 
 if ( ![iuuDee  isKindOfClass:[NSNull class]]){
               if ([iuuDee isEqualToString:myShareSingHS.uuidStringThing]) {
                   NSLog(@"Dude you have been BANNED");
                   // flag a message to be show //
                   // also add an option to do not display again flag // 
                   // remind me later // 
               }
           }

Now everything works fine.. also changed the MySQL type to BLOB.

Hope this helps.

blob for an uuid string?!
 

dejo

Moderator emeritus
Sep 2, 2004
15,982
452
The Centennial State
How are you getting UUID? Be aware that UIDevice's uniqueIdentifier property is now deprecated and only available for devices running iOS 2.0 through iOS 6.1.
 

MattInOz

macrumors 68030
Jan 19, 2006
2,760
0
Sydney
If your getting a NULL then that suggest to me your being returned a CFString not a NSString from the function feeding uuiDee.
 

IDMah

macrumors 6502
Original poster
May 13, 2011
316
11
Hi Dejo..

I found a uuid replacement -- somewhere on StackOverflow.

Code:
- (NSString *)uuidString {
    // Returns a UUID
    
    CFUUIDRef uuid = CFUUIDCreate(kCFAllocatorDefault);
    NSString *uuidStr = (__bridge_transfer NSString *)CFUUIDCreateString(kCFAllocatorDefault, uuid);
    CFRelease(uuid);
    NSLog(@"Generated uuid: %@",uuidStr);
    return uuidStr;
}
This should be ok with apple right? and I don't really care if it dies if the user deletes the app, because they deleted my app !!! Hahah!! but seriously it's just helps me keep track of players if I have to ban them..

In terms of the NULL I'm getting it from the mySQL, PHP. basically I want to keep it from crashing. I have tried various mySQL options and it's better I think to just check it in Xcode. I did set it to a NSString unless the JSON is returning the CFString..

i use this:
Code:
 NSURLRequest *request = [NSURLRequest requestWithURL:theLatestHighScoreURL];
    [NSURLConnection sendAsynchronousRequest:request
                                       queue:[NSOperationQueue mainQueue] 
                           completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {
                               // You have it.
                               NSLog(@"got data");
                               if (error) {
                                   NSLog(@"Something happended");
                               }else{
                               [self fetchedData:data];
                               }
                           }];
  }

and then "parse" the dictionary. is Parse the right term?
But basically the previous code works..

thanks
Ian
 
Last edited:

dejo

Moderator emeritus
Sep 2, 2004
15,982
452
The Centennial State
Hi Dejo..

I found a uuid replacement -- somewhere on StackOverflow.

Code:
- (NSString *)uuidString {
    // Returns a UUID
    
    CFUUIDRef uuid = CFUUIDCreate(kCFAllocatorDefault);
    NSString *uuidStr = (__bridge_transfer NSString *)CFUUIDCreateString(kCFAllocatorDefault, uuid);
    CFRelease(uuid);
    NSLog(@"Generated uuid: %@",uuidStr);
    return uuidStr;
}
This should be ok with apple right?

You sure that CFUUID is available for iOS and not just OS X?
 

chown33

Moderator
Staff member
Aug 9, 2009
10,739
8,415
A sea of green
I found a uuid replacement -- somewhere on StackOverflow.

See the Apple-recommended replacement for UDIDs on iOS here:
https://developer.apple.com/library...erence/UIDevice_Class/Reference/UIDevice.html

uniqueIdentifier
An alphanumeric string unique to each device based on various hardware details. (read-only) (Available in iOS 2.0 through iOS 6.1. Use the identifierForVendor property of this class or the advertisingIdentifier property of the ASIdentifierManager class instead, as appropriate, or use the UUID method of the NSUUID class to create a UUID and write it to the user defaults database.)
That extract is the discussion under the deprecated uniqueIdentifier property.

Also, the device's UDID (which is deprecated) is not the same as a UUID.

Since iOS has an NSUUID class, and that class has a method that returns an NSString, I don't see any point in writing code to make one from CFUUIDRef.
https://developer.apple.com/library...ence/Reference.html#//apple_ref/occ/cl/NSUUID
 

IDMah

macrumors 6502
Original poster
May 13, 2011
316
11
the "sales person" ;) the poster said it work for ios 7.
and so far it's worked on everything I've tried..

but will look at: UIDevice Class Reference

Like I said. I could have just as easily just created a unique random number generator,
just something to unique.

thanks.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.