For those struggling with this; the ONLY think I could do to get this to work was add this line of code:
tempButton.translatesAutoresizingMaskIntoConstraints = false
Post
Replies
Boosts
Views
Activity
The first part from line 1 to 20 is to create the 0x082C, now that I see how it reads. But the value is 0x2c08. So how do I get the flags data if the first and second bit are swapped? How do I create the flags correctly to then read them?
NSData *data = [characteristic value];
const uint8_t *byteData = [data bytes];
uint16_t flags = byteData[0];
I appreciate your help!
That gives me nothing that I can see. I'm trying to connect a raspberry pi 4. I think I have it connected in the bluetooth of the device. Now I am running the bluetooth scan for peripherals in my app and trying to find it. I have two devices that I cannot tell what they are so I need to read the manufacturer data and I can't. I've been able to take the nsinlinedata before and convert it to json but that was years ago and cannot find my code.
It was the image getting distorted. That is the crazy part. There is no text, no background or anything. A square button with a square image that you drag out of the ui library. Those “Unspecified “ settings caused the image to distort. Even though those settings appear to be for text only.
FINALLY! I figured it out. So the button seemed to me to be behaving like text was being added on the second user selection, very odd. So to fix this I selected the state config to "Selected." Then under the "Selected Symbol Configuration" panel, I set the "Configuration = Point Size" "Point Size = 17" "Scale = Default" "Weight = Regular." Then it works exactly as expected. My assumption was the previous entries for those fields being "Unspecified" was messing something up. All works well now. Thanks for your help. Hopefully this helps someone experiencing this weird UI behavior.
It appears to smash drastically verticallly. The first press works perfect and the ones after are distorted. I've been developing iOS apps for a decade and never seen this before. Button is CustomIt is an image with no content insetsIt is in the assetsTried every content modeImage is square 50 x 50 px @ 1xBehaves the same on device as simulator.
If these three things are true then the build fails:1. CocoaPods installed2. Plist contains $(CURRENT_PROJECT_VERSION) for "Bundle Version"3. Common Run Script installed for incrementing buildsHaving CocoaPods installed and having a Run Script installed seems to be very common.
Hilarious that I have looked and looked and tried virtually everything for about a month to fix this and the moment I post it in the forums, I figure it out. For whatever reason if your "Bundle Version" entry in your plist contains this: "$(CURRENT_PROJECT_VERSION)" then it won't work. It must contain a number. Then it works fine.
I believe I have it working. I tried to get both ways working and was able to get the cycle from PBK to work. Here is my code:-(void)cycleArray:(NSMutableArray *)array{
// vars
NSMutableArray *newArray = [array mutableCopy];
NSSortDescriptor *valueDescriptor = [[NSSortDescriptor alloc] initWithKey:@"value" ascending:YES];
NSInteger jokerCount = [self getJokerCount:newArray];
// check
if(jokerCount > 0){
// cycle
for(Card *card in array){
// check
if(card.value == CardJoker){
// cycle
for(int i = 0; i < fullDeck.count; i++){
// vars
Card *tempCard = [fullDeck objectAtIndex:i];
// replace
[newArray replaceObjectAtIndex:[array indexOfObject:card] withObject:tempCard];
// cycle
[self cycleArray:newArray];
}
}
}
}
else{
// vars
/*NSMutableArray *display = [NSMutableArray new];
// cycle
for(Card *card in newArray){
// vars
NSString *displayString = [NSString stringWithFormat:@"v:%d - s:%d", card.value, card.suit];
// add
[display addObject:displayString];
}
NSLog(@"cards at check: %@", display);*/
// vars
NSArray *newValueSortedArray = [newArray sortedArrayUsingDescriptors:@[valueDescriptor]];
HandRank newHandRank = [self getHandRank:newValueSortedArray];
// check
if(newHandRank > handRank){
// set
handRank = newHandRank;
//NSLog(@"new high rank %@", [self getHandRankName:handRank]);
}
}
}Thank you to everyone for all your help! This works although very slow when three or more jokers, it should work for now.
Following your psuedo code, I'm still lost. This for now just goes one by one and replaces the jokers 52 times. I don't understand how to send it back throug a cycle method?!?!?!?// vars
NSMutableArray *cardArray = [valueSortedArray mutableCopy];
// cycle
for(Card *card in valueSortedArray){
// check
if(card.value == CardJoker){
// cycle
for(int i = 0; i < fullDeck.count; i++){
// vars
Card *tempCard = [fullDeck objectAtIndex:i];
// replace
[cardArray replaceObjectAtIndex:[valueSortedArray indexOfObject:card] withObject:tempCard];
}
}
}
This works but I have to see if there are any more jokers and dig deeper into combinations. // vars
NSArray *jokersArray = [self makeArrayOfJokers:valueSortedArray];
NSMutableArray *noJokersArray = [self makeArrayofNoJokers:valueSortedArray];
HandRank highestRank = HandRankNone;
NSMutableArray *fullDeck = [NSMutableArray new];
// cycle
for(Suit suit = SuitClubs; suit <= SuitSpades; ++suit){
//NSLog(@"suit: %d", suit);
// cycle
for(int value = CardAce; value <= CardKing; ++value){
// create
Card *card = [[Card alloc] initWithSuit:suit value:value];
// add
[fullDeck addObject:card];
//NSLog(@"card %@ = suit: %d value: %d", card, card.suit, card.value);
}
}
// cycle
for(int i = 0; i < fullDeck.count; i++){
// vars
Card *card = [fullDeck objectAtIndex:i];
//NSLog(@"card %@ = suit: %d value: %d", card, card.suit, card.value);
// check
if(jokersArray.count > 1){
// cycle
for(int j = 0; j < fullDeck.count; j++){
// vars
Card *subcard = [fullDeck objectAtIndex:j];
NSMutableArray *newCardArray = [noJokersArray mutableCopy];
// add
[newCardArray addObject:card];
[newCardArray addObject:subcard];
// vars
NSArray *newValueSortedArray = [newCardArray sortedArrayUsingDescriptors:@[valueDescriptor]];
HandRank newHandRank = [self getHandRank:newValueSortedArray];
// check
if(newHandRank > highestRank){
// set
highestRank = newHandRank;
NSLog(@"new high rank %@", [self getHandRankName:highestRank]);
}
}
}
else{
// vars
NSMutableArray *newCardArray = [noJokersArray mutableCopy];
// add
[newCardArray addObject:card];
// vars
NSArray *newValueSortedArray = [newCardArray sortedArrayUsingDescriptors:@[valueDescriptor]];
HandRank newHandRank = [self getHandRank:newValueSortedArray];
// check
if(newHandRank > highestRank){
// set
highestRank = newHandRank;
NSLog(@"new high rank %@", [self getHandRankName:highestRank]);
}
}
}I just don't know how to make it dynamic in the depth for which it checks the combinations of jokers.
I'm lost. How can you call a method to get the next possible card? I'm so confused...
This prefix and suffix makes no sense to me. Trying to translate to objective c is also very difficult. Thanks for your help...
And that is how I have it and it works perfectly. However for more than one joker, you must replace all jokers and then test. Therefore you need every possible combination of jokers tested.
Thanks for your help. It isn’t what I’m after but that’s ok. I’ll just create different methods for the different numbers of jokers. These functions are for evaluating the hand score after a cards have been dealt. It is far easier to check the possible score/value of the hand by substituting the joker than it is to do it any other way. My goal was to say ok the cards have been dealt, let’s remove any jokers and replace it with a card and check the value of the hand. The only way to do that is that the joker has to be substituted for every possible value it can be and the check the value of the hand through my other existing functions.