Posts

Showing posts from July, 2018

Swift: Giving Context To Cgcontext (Part I)

First encounters alongside CGContext tin flaming hold upwards bewildering. We are presented alongside a lot of code that looks most dissimilar Swift together with to a greater extent than than probable it's inwards a drawRect: method of a UIView. So let's consider the entry signal to drawing: override func drawRect(rect: CGRect) { if permit context = UIGraphicsGetCurrentContext() { } } To explain, during the lifetime of a drawRect: in that location is a CGContext that nosotros tin flaming gain access to past times precisely calling UIGraphicsGetCurrentContext() as demonstrated above. Once nosotros convey the context, which is the house that we're going to hold upwards drawing to, nosotros tin flaming draw. And this drawing volition appear every fourth dimension a stance of our UIView subclass type is presented on screen. Demonstrating CGContext To demonstrate this, the showtime affair we're going to practise is to fill upwards the stance together with to

Swift: Array In Addition To Arrayslice (Xcode 7.3, Swift 2.2; Updated Xcode Eight Beta 6, Swift 3)

** Jump to Swift iii code ** Before nosotros begin Influenza A virus subtype H5N1 swell debt inwards writing this postal service is owed to a presentation yesteryear AirspeedVelocity at a Swift London lawsuit held inwards the Facebook offices inwards 2015. There he went into the depths of how arrays as well as other types are stored as well as copied inwards memory. Here I'm looking at a far to a greater extent than basic marker aimed at the practical implications of Array as well as ArraySlice when coding. Array Let's consider a humble array of type Array<Int>: var array = [1,2,3,4,5,6,7,8,9,10] If nosotros desire to yell upwards the foremost exceptional inwards the array nosotros tin produce the following: let firstItem = array.first Or nosotros tin subscript the array similar so: let firstItem = array[0] In both instances nosotros yell upwards an Int value. Slicing Now let's suppose nosotros possess got a hit from the master copy array to create

Swift: Sorting Togetherness Alongside Zip2sequence Together With Stable Kind Out (Xcode 7.2; Updated Swift 3, Xcode 8)

Let's human face upwardly it, of all the types inwards Swift, Zip2Sequence receives real piffling press. This doesn't hateful its role inwards the development of Swift has been forgotten at Apple. It merely way that by as well as large its role is  fulfilled using other approaches ( or mayhap beingness at the terminate of the alphabet us bloggers merely haven't addressed its purpose yet). The basics As the refer suggests, a Zip2Sequence is created past times zipping together 2 sequences. let firstArray = [1,2,3,4,5,6,7,8,9,10] allow secondArray = ["A","B","C","D","E","F","G","H","I","J"] // outset way of instantiating allow zipped1 = Zip2Sequence(firstArray,secondArray) // 2nd way of instantiating allow zipped2 = zip(firstArray, secondArray) Note: The 2 sequences save their master copy types, the expose of zipped together pairs is equally long equally the shortest of

Swift: Uibezierpath For Inscribed In Addition To Circumscribed Circles (Xcode 7.2.1)

Image
UIBezierPath has an inbuilt initialiser that returns an oval inward a rect together with of course of teaching nosotros tin move this to line circles yesteryear passing a square. However, assume yous convey a rectangular icon together with yous desire to mask it alongside a circle. For this you'll demand the inscribed circle non an oval. The minute scenario I desire to imagine is a circumscribed circle exterior the rect for where nosotros want, for example, text to period of time around a foursquare icon inward a UITextView. In gild to address this I started to intend virtually how nosotros line around an icon square. H5N1 foursquare text period of time is elementary to orbit alongside a rect larger than that of the image. Circular together with oval wraps pose a bigger problem: But alongside a piffling assistance from the Internet inward finding the correct equations all these things tin endure achieved: extension CGFloat { func radians() -> CGFloat { allow b =

Review: Gist Icon For Swift: Advanced Icon Processing For Ios Yesteryear Simon J Gladman

Image
Who is the bulk for? Core Image for Swift: Advanced Image Processing for iOS  is for those iOS in addition to OS X programmers who cause got exclusively actually used Core Image out of necessity for when UIImage was non capable of providing a solution in addition to right away wishing to acquire further. It is also for those who are already acquainted alongside Core Image in addition to wishing to delve deep into the frameworks of Core Image in addition to Metal. At every phase in addition to score of complexity the author, Simon Gladman, is in that place to guide us in addition to never exercise nosotros experience lone or laid adrift inwards this book. First impressions The start matter I noticed nearly this bulk was its purpose of the Apple textbook format. This gives it a clear in addition to concise feel. It is extremely visual, providing examples of the Core Image filters nether give-and-take (in static in addition to animated form) in addition to also clear code examp

Bytes For Beginners: Cook Your Ain Conversions From Int Together With Double To Binary (And Other Pose Out Bases) Inwards Swift (Update: Xcode 8, Beta 6; Swift 3)

Why convert a decimal to a binary yourself when Swift tin create it for you? String(500, radix:2) Well it helps inwards learning: extension Int { func binary() -> String { var num = self var str = "" repeat { str = String(num%2) + str num = num/2 } piece num > 0 supply str } } 500.binary() And every bit you lot tin run into the procedure of going from base of operations 10 to base of operations two is a straightforward exercise. We just keep  dividing past times the base of operations give away in addition to adding the remainder  to the commencement of our string. In fact going from base of operations 10 to whatever base of operations from two through to ix is straightforward, because nosotros tin create just the same matter for those give away bases too. extension Int { func toBase(b:Int) -> String { guard b > 1 && b < xi else { fatalEr

Adventures Inward Paypal: Starting Fourth Dimension Steps To Gaining An Access Token Using The Remainder Api

Spoiler alert : if you've come upwards hither to honor a solution on how to exercise the PayPal API amongst MAMP, hence I apologise inwards advance that I can't endure of help. I tin exclusively study the issues that I encountered when testing its compatibility. To begin So I've been dabbling inwards PayPal's REST APIs together with accept flora that spell using cURL from the OS X/macOS terminal is straightforward getting this materials working on my hosted website wasn't every bit straightforward without piecing together some code from but about the web. I'm non going to instruct through the steps of setting upwards a sandbox customer id together with hush-hush here, for that you lot require to instruct over to http://developer.paypal.com . I am also non going to tackle the plain of study of setting upwards the necessary PayPal describe of piece of job concern human relationship for utilising the API. Neither am I going to move into into how you lot obtain

Adventures Inwards Paypal: Missing Sum Together With Items

The sample code included hither volition enable you lot to brand a accuse through PayPal for a sure enough sum only unless you lot render a breakdown of the items beingness purchased together with then the fee beingness charged together with the items inside that accuse won't last displayed. <?php // http://stackoverflow.com/questions/15729167/paypal-api-with-php-and-curl // https://github.com/paypal/adaptivepayments-sdk-php/issues/24 // https://github.com/paypal/rest-api-curlsamples/blob/master/execute_all_calls.php // http://stackoverflow.com/questions/15885742/pay-with-paypal-through-paypal-rest-api-does-not-show-up-payment-description-on // Full payment capabilities // https://developer.paypal.com/docs/integration/direct/explore-payment-capabilities/ $host = 'https://api.sandbox.paypal.com'; $clientId = 'Replace amongst your clientId'; $secret = 'Replace amongst your secret'; $token = ''; part get_access_token($url, $postdata) { global $

Adventures Inwards Paypal: Executing The Sale

In gild to execute the sale you'll conduct hold a provide page setup where PayPal redirects to afterwards the client has paid. Since the user is going away from the page together with returning to either the same i or a novel i you lot involve to abide by a agency of storing the access token hence that you lot tin utilization this i time to a greater extent than for execution. While it's truthful that you lot tin exactly create a novel access token, together with this volition hold upwards as valid for performing the execution, what you lot are meant to exercise is to utilization access tokens until their death (which occurs 8–9 hours afterwards their creation). So inward all likelihood the access token volition hold upwards active when the user returns from PayPal. To address this it is possible to shop the token as a cookie or inward session storage. Session storage keeps the information on the server together with cookies salvage to the user's machine. So session st

My Favourite Ios Evolution Bugs

There are some things inwards iOS evolution that tin actually choose grip of you lot out the get-go fourth dimension you lot run into them in addition to of late I was inspired to brand a listing every bit in addition to when I scream back them. This way that I volition add together to this post over fourth dimension every bit I recall things. I laid out alongside 2 issues. The get-go is a mutual effect on StackOverflow. 1. NSUserDefaults non storing values When testing something it is mutual to throw everything inwards viewDidLoad: but the employment inwards the instance of NSUserDefaults is that it stores information asynchronously in addition to thus if you lot endeavor in addition to at nowadays retrieve what you lot accept but stored thus it commonly isn't there. The solution is to delay the retrieval, using for illustration a push that triggers the retrieval after for testing purposes. Or synchronise() the user defaults. 2. UIDocumentInteractionController crashes my ap

Verifying For Unhappily Always After: How To Skip Verification On Xcode Eight Beta 6

Quite a few people convey works life that verification of Xcode viii beta half dozen is around endless as well as may good endure endless because nosotros never genuinely driblet dead to the halt earlier aborting. It turns out a solution was posted to stackoverflow to solve this issue: Open Terminal Enter the next command: xattr -d com.apple.quarantine /Applications/Xcode-beta.app Double tap the app equally green to open as well as I tin sack confirm that it worked for me. It's non something that Apple recommends because it skips verification only for those of us who desire to driblet dead Xcode viii beta half dozen upwards as well as running it sure enough helps.  Alternatively you lot tin sack follow Apple's advice as well as file a põrnikas report, as well as thus wait, the alternative is yours. Follow @sketchytech

Taming Nsdocument Too Agreement Who's Boss: Creating A Unproblematic Macos Text Editor (Swift 3, Xcode Viii Beta 6)

Image
Looking at Apple's diagrams inward their documentation nosotros meet that NSDocumentController is boss of NSDocument, which inward plough is boss of NSWindowController together with this leads to the document window beingness displayed. Yup, but what is actually happening together with what does this hateful inward price of code? Creating the project As with other apps, create a novel projection together with choose macOS Cocoa every bit the type: And having clicked next, brand certain you lot choose the "Create Document-Based Application" checkbox: Navigating the Files When a document-based app is created amongst the familiar AppDelegate together with ViewController files nosotros convey Document.swift every bit well. This concluding shape file providing a subclass of NSDocument. The most of import matter to banknote origin of all is that: the ViewController shape does not ain or create an instance of our NSDocument subclass (i.e. Document) the

My Favourite Macos Evolution Bugs

1. Changing the Background Colour Influenza A virus subtype H5N1 elementary matter to create inwards iOS is to alter the background colouring cloth of a sentiment simply inwards macOS you lot necessitate to showtime tell the sentiment you lot desire the layer together with and hence reference the layer. And in conclusion you lot necessitate to overstep away it a CGColor rather than an NSColor. 2. NSTextView NSTextView together with the means it interacts alongside NSScrollView is a whole tin of worms that I'm working on getting my caput around. But 1 of the showtime hurdles is that if you lot are working alongside the element parts: NSLayoutManager, NSTextContainer together with NSTextStorage – together with hence you lot must retain a reference to the text store for it to survive equally expected. Follow @sketchytech

Solving Onedrive Syncing Problems On Mac

In damage of value for coin I rank OneDrive 10/10 but it tin confront a few syncing issues inwards day-to-day use. Syncing problems tin endure caused yesteryear path length: "The entire path, including the file name, must comprise fewer than 255 characters. Shorten the lift of your file or the lift of subfolders inwards OneDrive, or choose a subfolder that's closer to the top-level folder." They tin too endure caused yesteryear role of sure enough symbols inwards file names, in addition to yesteryear private files over 1 GB inwards size. If whatever of these issues come about you lot should encounter a alert symbol seem on the OneDrive paradigm inwards your bill of fare bar in addition to at that spot should endure an selection seem when you lot click on the paradigm to inspect in addition to right these errors. Aside from these esoteric errors, it sometimes occurs that OneDrive, nearly oft at the to the lowest degree convenient time, exactly cannot progress amongst