Search code examples
iosobjective-ccbperipheral

how to use getBytes:length?


- (int) compareCBUUID:(CBUUID *) UUID1 UUID2:(CBUUID *)UUID2 {

    char b1[128];
    char b2[128];
    [UUID1.data getBytes:b1];
    [UUID2.data getBytes:b2];
    if (memcmp(b1, b2, UUID1.data.length) == 0)return 1;
    else return 0;
}

How I can convert above method to use getBytes:length in above method ?

Thanks


Solution

  • Why so hard? Just:

    - (int)compareCBUUID:(CBUUID *) UUID1 UUID2:(CBUUID *)UUID2 {
        return (int)(UUID1 == UUID2 || [UUID1 isEqual:UUID2]);
    }