Posts

Post not yet marked as solved
1 Replies
353 Views
I am using aws amplify and it returns all of its results into models and their type is something like List. But I would like them in standard swift arrays so I can use all the functionality like .first and such. How can this be done easily? My error: Cannot convert value of type 'List?' to expected argument type '[ResourceSubCategory]' Thank you!
Posted Last updated
.
Post not yet marked as solved
1 Replies
244 Views
I have a view controller called new student. When a new student is saved, the dataprovider sends the data onto the apiservice and the new student has items uploaded. In the api service file there is a progress of the upload process. How can I broadcast that progress from the apiservice so that the new student class can listen for it without using delegates?
Posted Last updated
.
Post not yet marked as solved
2 Replies
1.2k Views
I'm trying to use the new uibutton configuration and it doesn't receive touches. What am I missing? Adding other buttons the "old fashioned" way work just fine. var configuration = UIButton.Configuration.filled() configuration.buttonSize = .large configuration.title = "Swift" configuration.image = UIImage(systemName: "swift") configuration.imagePlacement = .trailing configuration.titlePadding = 10 configuration.imagePadding = 10 configuration.contentInsets = NSDirectionalEdgeInsets(top: 10, leading: 10, bottom: 10, trailing: 10) let tempButton = UIButton(configuration: configuration) tempButton.addAction(UIAction(handler: { action in print("new touched") }), for: .touchUpInside) self.view.addSubview(tempButton)
Posted Last updated
.
Post marked as solved
5 Replies
2.1k Views
For years I have had a run script (below) that increments my builds for me. I recently switched to using coocapods for my sdk's. Now having the run script makes the build fail with error.line 3: $(CURRENT_PROJECT_VERSION) + 1: syntax error: operand expected (error token is "$(CURRENT_PROJECT_VERSION) + 1")Command PhaseScriptExecution failed with a nonzero exit codebuildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$INFOPLIST_FILE") buildNumber=$(($buildNumber + 1)) /usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "$INFOPLIST_FILE"Thoughts?
Posted Last updated
.
Post not yet marked as solved
2 Replies
845 Views
I had to purchase an M1 mac a couple months ago to get me until I can afford the mac studio because my i7 custom 27" 5K was dying. After the most recent update of Xcode I have nearly a full second before each key typed displays. 25 years plus experience with computers. Tried everything to keep my memory from being used so much. 13.3.1 leaves me with roughly 60mb's free. Dog slow! I can't do anything! Anyone else have this issue?
Posted Last updated
.
Post not yet marked as solved
3 Replies
3.0k Views
I have two paths on two separate layers/views that intersect at only one point. I need to find the point of intersection. I've searched and can't seem to find how this is possibe.The light grey vertical line intersection point with the blue line graph. Both paths are UIBezierPaths. Is there a method to get a array of insection points? Which in my case would return one result?
Posted Last updated
.
Post not yet marked as solved
1 Replies
739 Views
I have a series of apps that use the same user database. With my Facebook and email/password logins this is easy to identify the same user. However, the sign in with Apple creates a different user_id for the same user across my group of apps. How do I allow the same user to login with the same user_id across the app group?
Posted Last updated
.
Post not yet marked as solved
1 Replies
702 Views
Could someone be so kind to help me convert this swift to objective c? I'm trying to create a signature for an api and I am having no luck. let nonce = Int64(Date().timeIntervalSince1970 * 1000000)      postdata = "\(serviceRequest)nonce=\(nonce)"            let hash = ("\(nonce)"+postdata).sha256!            let hashData = hash.data(using: .bytesHexLiteral)!            let binaryData = path.data(using: .utf8, allowLossyConversion: false)!            let lenTotal = binaryData.count + hashData.count      var pathSh256 = Data(capacity: lenTotal)      for i in 0..binaryData.count {      let j = binaryData.index(binaryData.startIndex, offsetBy: i)      let bytes = binaryData[j]      pathSh256.append(bytes)      }      for i in 0..(hashData.count) {      let j = hashData.index((hashData.startIndex), offsetBy: i)      let bytes = hashData[j]      pathSh256.append(bytes)      }            let APISecret = APISecret ?? ""      let secretDecoded = Data(base64Encoded: APISecret, options: .ignoreUnknownCharacters)!      let sign = HMAC.sign(data: pathSh256, algorithm: .sha512, key: secretDecoded)      let apiSign = String(data: (sign.base64EncodedData()),encoding: String.Encoding.utf8)! What I have so far but it is invalid: NSString *postDataToHashString = [NSString stringWithFormat:@"%@%@", nonce, [NSString stringWithFormat:@"nonce=%@", nonce]];     const char* utf8chars = [postDataToHashString UTF8String];     unsigned char result[CC_SHA256_DIGEST_LENGTH];     CC_SHA256(utf8chars, (CC_LONG)strlen(utf8chars), result);     NSMutableString *hashString = [NSMutableString stringWithCapacity:CC_SHA256_DIGEST_LENGTH*2];     for(int i = 0; iCC_SHA256_DIGEST_LENGTH; i++) {         [hashString appendFormat:@"%02x",result[i]];     }     NSString *dataStringToHmac = [NSString stringWithFormat:@"/0/private/QueryOrders%@", hashString];     NSData *decodedData = [[NSData alloc] initWithBase64EncodedString:apiSecret options:0];     NSString *decodedSecret = [[NSString alloc] initWithData:decodedData encoding:NSASCIIStringEncoding];     NSStringEncoding thisEncoding = NSUTF8StringEncoding;     uint16_t digest_length[CC_SHA512_DIGEST_LENGTH]={0};     const char *constantString = [dataStringToHmac cStringUsingEncoding:NSUTF8StringEncoding];     NSData *stringData = [NSData dataWithBytes:constantString length:strlen(constantString)];     NSString *key = decodedSecret;     NSData *keyData = [key dataUsingEncoding:thisEncoding];     CCHmac(kCCHmacAlgSHA512, keyData.bytes, keyData.length, stringData.bytes, stringData.length, digest_length);     NSData *hMacHashedData = [NSData dataWithBytes:digest_length length:CC_SHA512_DIGEST_LENGTH];     NSData *hMacHashData = [[hMacHashedData description] dataUsingEncoding:thisEncoding];     NSString *hMacHashBase64 = [hMacHashData base64EncodedString]; What it looks like in php: if(!isset($request["nonce"])) {      // generate a 64 bit nonce using a timestamp at microsecond resolution      // string functions are used to avoid problems on 32 bit systems      $nonce = explode(' ', microtime());      $request["nonce"] = $nonce[1] . str_pad(substr($nonce[0], 2, 6), 6, '0');      }      // set      $postdata = http_build_query($request, '', '&');      $sign = hash_hmac('sha512', $path . hash('sha256', $request["nonce"] . $postdata, true), base64_decode($secret), true);      $headers = array(      'API-Key: ' . $key,      'API-Sign: ' . base64_encode($sign)      ); HELP! Thank you in advance
Posted Last updated
.
Post not yet marked as solved
1 Replies
441 Views
I'm working in the latest Xcode with my iPhone 12 Pro Max. I've built an app that I'm trying to get push notifications to work on. I've never had an issue in over a decade. However, I've discovered that my firebase notifications work just fine on all devices except the ones used to install the app and test through Xcode. Even after I have downloaded the app from TestFlight so I know it is signed with the production provisioning profile. Is there any way to clear development profiles from the devices? Seems like it is hanging around and blocking the push notification because it is signed in dev mode. It's not refreshing to the new TestFlight version
Posted Last updated
.
Post not yet marked as solved
3 Replies
471 Views
I'm dying here! Spent so many hours trying to understand how to get this bluetooth characteristic data to parse. My device is a cycling power meter which has the first two bits as the flags for the device. This is where my issue is. I can connect just fine to devices with one bit as the flag but two is killing me. Characteristic: <CBCharacteristic: 0x282298f00, UUID = 2A63, properties = 0x10, value = {length = 12, bytes = 0x2c080000235134005e4348f0}, notifying = YES> NSData *data = [characteristic value]; const uint8_t *byteData = [data bytes]; uint16_t flags = byteData[0]; NSLog(@"measurement flag byte %lu", (unsigned long)flags); NSLog(@"flag bit 0: %d", (bool)(flags & 0x00)); NSLog(@"flag bit 1: %d", (bool)(flags & 0x01)); NSLog(@"flag bit 2: %u", (bool)(flags & 0x02)); NSLog(@"flag bit 3: %d", (bool)(flags & 0x03)); NSLog(@"flag bit 4: %d", (bool)(flags & 0x04)); NSLog(@"flag bit 5: %d", (bool)(flags & 0x05)); NSLog(@"flag bit 6: %d", (bool)(flags & 0x06)); NSLog(@"flag bit 7: %d", (bool)(flags & 0x07)); NSLog(@"flag bit 8: %d", (bool)(flags & 0x08)); NSLog(@"flag bit 9: %d", (bool)(flags & 0x09)); NSLog(@"flag bit 10: %d", (bool)(flags & 0x10)); NSLog(@"flag bit 11: %d", (bool)(flags & 0x11)); NSLog(@"flag bit 12: %d", (bool)(flags & 0x12)); offset = offset + 2; uint16_t powerMeasurment = CFSwapInt16LittleToHost(*(uint16_t *)(&[[characteristic value] bytes][offset])); NSLog(@"Power: %u", powerMeasurment); offset = offset + 2; I believe based on the data I think the flags should be "844" Which is swapping the first and second bit and concatenating them. Then I'm not sure if I am getting the bit from the flags correctly either, I'm a mess. Thank you greatly in advance.
Posted Last updated
.
Post not yet marked as solved
2 Replies
1k Views
I have a string of bytes: "0x00" and I need to convert it to a readable string which I believe should be "00". How do I do this? I've tried this: NSUInteger length = [@"0x00" length]; NSData *sizeData = [NSData dataWithBytes: &length length: sizeof(length)]; But that isn't creating data with the actual bytes just the length. Anything I do with bytes crashes my test.
Posted Last updated
.
Post not yet marked as solved
1 Replies
951 Views
I have an iOS app that will communicate with a bluetooth device via TCP. One issue we are having is that common ports like 8080 are blocked on some networks. Do you think it would be possible to create a method that scans for open ports if the "starting port" is blocked? If so, what would that look like with psuedo code?1. Start function to scan and find up to 5 (can be any number really) open ports2. Create a tcp connection starting at port 80003. If connection successful, add to array of successful ports4. If connection fails, add to array of failed ports5. Check if successful array has 5 items6. If yes then stop loop7. If no then repeat steps 2-7This could all be done on a background thread with GCD, yes? Is this something that would get an app declined for the App Store?Thanks in advance!
Posted Last updated
.
Post not yet marked as solved
1 Replies
1.8k Views
I'm having trouble upgrading my block to iOS 13 and I cannot find an example anywhere on the web. What am I missing here?[[PHImageManager defaultManager] requestImageDataAndOrientationForAsset:tempAsset options:options resultHandler:^(NSData * _Nullable imageData, NSString * _Nullable dataUTI, UIImageOrientation orientation, NSDictionary * _Nullable info){ }];Gives me an error of: Incompatible block pointer types sending 'void (^)(NSData * _Nullable __strong, NSString * _Nullable __strong, UIImageOrientation, NSDictionary * _Nullable __strong)' to parameter of type 'void (^ _Nonnull)(NSData * _Nullable __strong, NSString * _Nullable __strong, CGImagePropertyOrientation, NSDictionary * _Nullable __strong)'Thank you!
Posted Last updated
.
Post not yet marked as solved
3 Replies
2.0k Views
I'm connecting to a bluetooth peripheral and I have a key in my adverstising dictionary that I need to convert to a string. I cannot for the life of me figure out how to take the key and convert it to a string. See below. I'm using objective-c. Thanks!kCBAdvDataManufacturerData = {length = 34, bytes = 0x03000030 64000007 8c861e47 5e581200 ... 5888c626 f1088712 };
Posted Last updated
.
Post marked as solved
6 Replies
1.3k Views
I have a simple uibutton with an image on the selected state. When the button is selected the first time it works perfectly. The second time it is set to selected the image is distorted. What the heck is happening?!?!?!?I would post pics but apparently that isn't an option.
Posted Last updated
.