Post

Replies

Boosts

Views

Activity

Incorrect Thumbnail, File Filter broken
Hey there, My app is having a weird glitch after it is used several times. When the app is first installed, or running from Xcode, there is no glitch or error which is making this even harder to diagnose. The app stores videos as MP4's and presents them in a tableview. It then creates a thumbnail and stores that as a JPG with a matching name, which is displayed in the tableview. The glitch that's occurring is the thumbnail doesn't match the video! I'll post my code for you guys to break apart. 1. func setJpg(){ 2. 3. var jpgNames : [String] = [] 4. 5. for string in jpgSTRINGS{ 6. let url = URL(string: string) 7. jpgNames.append(url!.lastPathComponent) 8. } 9. 10. 11. func setJpg(){ 12. 13. var jpgNames : [String] = [] 14. 15. for string in jpgSTRINGS{ 16. let url = URL(string: string) 17. jpgNames.append(url!.lastPathComponent) 18. } 19. 20. 21. let droppedFormat = dropIntLast(string: videoString, int: 4) 22. let filtered = jpgNames.filter{$0.hasPrefix(droppedFormat + ".jpg")} 23. if (filtered.isEmpty){ 24. if (jpgMessages.count != videoURLS.count){ 25. let resultArrays = checkJpgs(jpgSTRINGS: jpgSTRINGS, videoURLS: videoURLS) 26. jpgMessages = resultArrays.first! as! [String] 27. }else{ 28. print ("this right here maybe?") 29. } 30. let videoPosition = videoURLS.firstIndex(of: videoURL!) 31. if (jpgMessages[videoPosition!] == ("The operation could not be completed")) || (jpgMessages[videoPosition!] == ("Cannot Open")) { 32. firstFrame.image = #imageLiteral(resourceName: "error") 33. } 34. } 35. 36. // --------if (filtered.isEmpty == false)-------- 37. else{ 38. 39. let name = videoURL!.lastPathComponent 40. let fixedNameOne = name.replacingOccurrences(of: " ", with: "%20", options: .literal) 41. let fixedNameTwo = fixedNameOne.replacingOccurrences(of: "–", with: "%E2%80%93", options: .literal) 42. let fixedNameThree = fixedNameTwo.replacingOccurrences(of: "#", with: "%23", options: .literal) 43. let path = videoURL?.deletingLastPathComponent() 44. let string = path!.absoluteString + dropIntLast(string: fixedNameThree, int: 4) + ".jpg" 45. urlJpg = URL(string: string) 46. do { 47. let data = try Data(contentsOf: urlJpg!, options: [.mappedIfSafe, .uncached]) 48. let photo = UIImage(data: data) 49. firstFrame.image = photo 50. } 51. catch { 52. Swift.print("Error in Data reading ", error) 53. } 54. } 55. } Basically, I have references to the JPG's and MP4's as URLs in arrays, as well as String arrays. videoString is the name of the MP4 referenced in the form of a string, which is the comparator for the filter. Line 22 filters though the jpgSTRINGS array to find the matching name there. If it can't find a matching name it will use my function checkJpgs to create one, or it will detect the MP4 is corrupt and a thumbnail can't be created and will use a default Error Icon. If it detects a JPG with a matching name it will get the find the file path and display that. When the glitch occurs, it either displays the wrong thumbnail or the Error Icon. This makes me think the issue is on line 5 or 22, but I don't know how this is possible. The fact I can't replicate this issue when running from Xcode make it that much more to diagnose and collect data. I'm sure there's a better way to filter through the JPGs but I'm not away of it. If anyone has any idea how to make this more efficient or less error prone please point me in the right direction.
0
0
152
Sep ’24
SKRefreshReceipt latest_receipt_info order of purchases is wrong
My app utilizes auto-renew subscriptions. To check the status I refresh the receipt, validate it with the iTunes servers, and check the expiration date of the last object of "latest_receipt_info"if let receiptInfo: NSArray = json["latest_receipt_info"] as? NSArray{ let lastReceipt = receiptInfo.lastObject as! NSDictionary let productid: String = lastReceipt["product_id"] as! String let bundleid: String = Bundle.main.bundleIdentifier! + ".monthly" let expirationDate: Date = (formatter.date(from: lastReceipt["expires_date"] as! String) as Date?)! }The issue I'm having is that the order of receipts in "latest_receipt_info" is completely wrong. The order is constantly changing. I was having no issues with this until today. Could this be a bug, or am I doing something wrong?
2
0
689
May ’20
Can't get rid of space at top of UITableView
I have a UITableView inside a UIViewController (not UITableViewController) with a UISearchBar at the top of the table view that's shown and hidden via a search button on the UINavigationBar. When you scroll to the top the table view's background is shown above the search bar. I've been doing a lot of research and can't figure this out. PLEASE HELP!!http://i1152.photobucket.com/albums/p493/-roar/Image-1_zpswgtd0w6d.jpgmake sure your ad blocker is on before clicking the link. lots and lots of ads
8
0
4.6k
Nov ’17