Reputation:
How can I convert a NSUUID
to NSString
?
NSString *url = [self mysql_process:ESTIMOTE_PROXIMITY_UUID];
- (NSString*)mysql_process:(NSUUID *)beacon_id
{
NSString *strURL = [NSString stringWithFormat:@"http://path_to_php_file/mysql.php?id=%@", beacon_id];
NSData *dataURL = [NSData dataWithContentsOfURL:[NSURL URLWithString:strURL]];
NSString *strResult = [[NSString alloc] initWithData:dataURL encoding:NSUTF8StringEncoding];
return strResult;
}
When I try to NSLog
the URL
im getting a pointer, which shows me my NSUUID
, ESTIMOTE_PROXIMITY_UUID
in this case.
Upvotes: 2
Views: 1902
Reputation: 69
swift 3 version
Ex:
let uuidStringValue = "12345678-1111-2222-3333-4567891012B4"
let proximityUUID = NSUUID(uuidString: uuidStringValue)
Upvotes: 1
Reputation: 36447
NSString *url = [self mysql_process:ESTIMOTE_PROXIMITY_UUID];
- (NSString*)mysql_process:(NSUUID *)beacon_id {
**NSString *strDeviceUUID = [beacon_id UUIDString];** // Converts NSUUID to UUIDString format
NSLog(@"beacon_id : %@ strDeviceUUID : %@ ", beacon_id,strDeviceUUID);
NSString *strURL = [NSString stringWithFormat:@"http://path_to_php_file/mysql.php?id=%@", strDeviceUUID];
NSData *dataURL = [NSData dataWithContentsOfURL:[NSURL URLWithString:strURL]];
NSString *strResult = [[NSString alloc] initWithData:dataURL encoding:NSUTF8StringEncoding];
return strResult;
}
This function is present in NSUUID.h file of Foundation frameworks.
/* Return a string description of the UUID, such as "E621E1F8-C36C-495A-93FC-0C247A3E6E5F" */
- (NSString *) UUIDString;
Upvotes: 0
Reputation: 5369
If you want NSString from NSUUID. Use UUIDString of NSUUID...
NSUUID *uuidStringRef = [[UIDevice currentDevice] identifierForVendor];
NSString *stringRef = [uuidStringRef UUIDString];//you can replace uuidStringRef with your ESTIMOTE_PROXIMITY_UUID
Hope it helps you...!
Upvotes: 0
Reputation: 26016
NSUUID
has a method: -(NSString*)UUIDString;
.
So:
NSString *uuidString = [yourNSUUID UUIDString]
Upvotes: 13