[Solved] Is HealthKit query on WatchOS limited?

The issue was that on iPhone HKHealthStore returns all records, however on watch only records added by release versions of the app are fetched. That’s why I didn’t see the same data on watch as on iPhone. solved Is HealthKit query on WatchOS limited?

[Solved] Posting a comment on friend’s Facebook wall with an iOS SDK [closed]

NSString *urlString = [NSString stringWithFormat:@”https://graph.facebook.com/YOUR_FRIEND_FB_ID/photos?access_token=%@“, self.accessToken]; UIImage * pic = [UIImage imageNamed:@”green-background.png”]; NSData *picData = UIImageJPEGRepresentation(pic, 1); NSURL *url = [NSURL URLWithString:urlString]; ASIFormDataRequest *newRequest = [ASIFormDataRequest requestWithURL:url]; [newRequest setPostValue:@”This is Sample Text” forKey:@”message”]; [newRequest setData:picData forKey:@”data”]; [newRequest setPostValue:self.accessToken forKey:@”access_token”]; [newRequest setDelegate:self]; [newRequest setDidFinishSelector:@selector(postToWallFinished:)]; [newRequest startAsynchronous]; solved Posting a comment on friend’s Facebook wall with an … Read more

[Solved] Objective – C to Swift : NSData with NSJSONSerialisation

Instead of JSONSerialization.jsonObject(with:) you are using NSKeyedUnarchiver, Also use native Data instead of NSData. var json = [AnyHashable:Any]() if let filePath = Bundle.main.path(forResource: “realstories”, ofType: “json”), let data = try? Data(contentsOf: URL(fileURLWithPath: filePath)), let dic = (try? JSONSerialization.jsonObject(with: data)) as? [AnyHashable:Any] { json = dic } solved Objective – C to Swift : NSData with … Read more

[Solved] Using the Swift Contacts Framework

I think it would be best to pull from the device’s Contacts, using the Contacts Framework – in Xcode this is the Contacts.framework package. The Apple site offers some sample code that you might be able to take advantage of in your application. For that you’d need permission from the user by enabling a NSContactsUsageDescription … Read more

[Solved] How to draw a circle and move it / drag it on touch in IOS? [closed]

Well you could create a custom UIView and overwrite it’s drawRect method to draw the circle. The drawRect method would then look like this: – (void)drawRect:(CGRect)rect { CGContextRef ctx = UIGraphicsGetCurrentContext(); CGContextSetFillColorWithColor(ctx, [[UIColor redColor] CGColor]); CGContextFillEllipseInRect(ctx, self.bounds); } Don’t forget to set the views background color to the clear color. To handle the movement, add … Read more

[Solved] How to add UILabel from a loop? [closed]

You should actually create the label and place it on your view. UILabel *display = [[UILabel alloc] init]; display.text = [chars objectAtIndex:i]; display.frame = CGRectMake(x, y, 14, 22); display.textColor = [UIColor whiteColor]; [self.view addSubView:display]; solved How to add UILabel from a loop? [closed]

[Solved] How to get minimum & maximum value in a NSString/String array?

@user3815344’s answer works, however you can simplify it by using minElement and maxElement to retrieve the minimum and maximum values. For example: let arr = [“55a”, “95a”, “66”, “25”, “88b”, “#”] let numbers: [Int] = arr.reduce([]) { if let num = “”.join($1.componentsSeparatedByCharactersInSet(NSCharacterSet.decimalDigitCharacterSet().invertedSet)).toInt() { return $0 + [num] } return $0 } minElement(numbers) // 25 maxElement(numbers) … Read more

[Solved] how to have UIImage below UILabel or UITextView in a scrollview

You must implement your UIScrollView and then add the desired subview (UIImageView and UILabel in your case). In you viewDidLoad: UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)]; scrollView.backgroundColor = [UIColor redColor]; UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, scrollView.frame.size.width * 2, 100)]; imageView.backgroundColor = [UIColor blueColor]; UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(imageView.frame.size.width, 0, … Read more

[Solved] Populate CollectionView and TableView using objects at different index of same array [closed]

You can use filter method of array: //this filter will return you all objects whose group type is equal to 1 let collectionArray = (product_groups?.filter({$0.group_type == 1})) //this filter will return you all objects whose group type is equal to 2 let tableArray = (product_groups?.filter({$0.group_type == 2})) For group title to be section header: – … Read more