<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Moshe Berman on Medium]]></title>
        <description><![CDATA[Stories by Moshe Berman on Medium]]></description>
        <link>https://medium.com/@bermaniastudios?source=rss-ff4dee80c99f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*C3wBFmd74PobBle_-z-IKg.jpeg</url>
            <title>Stories by Moshe Berman on Medium</title>
            <link>https://medium.com/@bermaniastudios?source=rss-ff4dee80c99f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 17:47:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@bermaniastudios/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Putting the Pro in iPad Pro]]></title>
            <link>https://medium.com/@bermaniastudios/putting-the-pro-in-ipad-pro-9b12cac816bd?source=rss-ff4dee80c99f------2</link>
            <guid isPermaLink="false">https://medium.com/p/9b12cac816bd</guid>
            <category><![CDATA[ipad]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[uikit]]></category>
            <dc:creator><![CDATA[Moshe Berman]]></dc:creator>
            <pubDate>Mon, 29 Aug 2016 13:00:01 GMT</pubDate>
            <atom:updated>2016-08-31T11:42:00.898Z</atom:updated>
            <content:encoded><![CDATA[<p>There was a lot of talk a few months ago about Apple’s marketing of the iPad Pro, and how they are positioning it as a PC replacement. In order for app developers to produce professional-level content creation apps, Apple needs to create more complex and generalized user-facing developer components that are designed for the human finger.</p><p>Folks are talking about all kinds of things, from split screen multitasking, to drag and drop. Some contend that adding a mouse is a requirement for a serious computing platform, while others focus on flaws in the App Store model.</p><p>The key part of content creation is the creation tool itself. The kind of content created is directly dependent on the tool used.</p><p>In order for apps to support the complex kinds of content that pro users demand, it needs to be built in to the software’s DNA. Hardware accessories alone aren’t sufficient. The software development kit that Apple provides needs pro components.</p><p>The trouble for the iPad is that we’re essentially using the same basic building blocks as we were on the iPhone in iOS 3.0, with a view exceptions. There are a few new things, such as Stack Views, which allow developers to split the screen within their app, and Popovers which give us those transient tooltip overlays for quick tasks within an app.</p><p>But expecting app developers to build professional apps with the current UIKit is like asking a chef to make a pizza with only flour, and water. Without more ingredients it’s not pizza.</p><p>If we want iPads (of any flavor, be it Air, Pro, or baby Pro) to flourish as content creation devices, the off-the-shelf software development components need to be more diverse. I think a really good example of this is the new Swift Playgrounds app.</p><p>Apple did a phenomenal job with the user interface there. There are a few aspects of the app which made be take a step back and go “Huh. That would awesome if it were available as a UIKit component.” The number pad, specifically, with its circular slider and precise value types was pretty cool.</p><p>Apple’s use of the Autosuggest bar above the keyboard was also very well done. Contextual suggestions work well to eliminate inputs that are irrelevant in a given context to make the user more productive with their so-called “imprecise” finger input.</p><p>The iPad already has a ton of great hardware inputs, including the touch screen, cameras, and microphones, but when it comes to providing content creation software ingredients, the ones on the shelf are starting to get stale.</p><p>This matters because not every app developer is going to be able to design the right user interface for their use case. If developing a pro app requires that much more custom design, not every indie will go for it.</p><p>When the iPad came out, Apple’s Human Interface Guidelines for developers explained that the larger screen provided for more opportunities for custom interfaces. Remember, though, skeuomorphism was at its prime then, and there was tons of real world inspiration.</p><p>Even then, though, iPad apps were a bit of a free for all in terms of design. Either your iPad app was really great, or it wasn’t. I don’t remember a lot of consistency on the platform. Every app did large screens a little differently.</p><p>That said, there’s a lot of potential for pro apps on iOS, but we need to step back and think about the core tenets of creation. iOS developers are not supernatural powers, and as such cannot create something from nothing. Developers and iPad users need proper tools to get the job done. Apple can help get us there.</p><p>What if Apple expanded the Xcode templates to do different layouts, depending on industry? For example, an audio video starter template might include a timeline component and a split screen on either side. A productivity app would have the menu already coded up.</p><p>At a more basic level, extending sliders on iOS to support vertical positioning, rounding to an interval, and displaying the precisely selected value for scientific applications would be a nice set of enhancements.</p><p>Inline media pickers and file pickers would be great too. Maybe make them popover based on iPad. A simple callback block when the selected set changes would be a good start.</p><p>Pro apps would also benefit from calendar and password user interfaces that developers can plug into their own apps. The list goes and on, and I’m hopeful that someone at Apple might see this and say, gee that’s not a terrible idea.</p><p>If the tentpole features of iOS releases are any indication, Apple is indeed working on the problem of creating iPad software for professionals. If iOS 6 and 7 gave us Maps, Passbook (now Wallet), and freed our content consumption from stitched leather and green felt, iOS 8 and 9 gave us app extensions and multitasking to move our content more freely between apps. iOS 10 is going even further with systemwide features such as Continuity Clipboard and iMessage sticker packs.</p><p>Sticker packs are cool, but hardly pro-level content. They, like Swift playgrounds are a means to a better pro iPad world by way of example, but a professional user interface framework on top of their existing one would work wonders.</p><p><em>Originally published at </em><a href="http://blog.mosheberman.com/putting-the-pro-in-ipad-pro/"><em>Thoughts of a New Yorker</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9b12cac816bd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Core Data and Core Location]]></title>
            <link>https://medium.com/@bermaniastudios/core-data-and-core-location-7751ff24656f?source=rss-ff4dee80c99f------2</link>
            <guid isPermaLink="false">https://medium.com/p/7751ff24656f</guid>
            <category><![CDATA[core-location]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[core-data]]></category>
            <category><![CDATA[mapreduce]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Moshe Berman]]></dc:creator>
            <pubDate>Tue, 12 Jul 2016 03:58:33 GMT</pubDate>
            <atom:updated>2016-07-12T03:58:36.689Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Core Data by Core Location" src="https://cdn-images-1.medium.com/max/277/0*VAI_j4nOo2SGcdER.png" /></figure><p>I’m building an app that is supposed to track user location and sort a bunch of venues based on where the user is on the latitude/longitude coordinate system relative to those venues. I’m using Objective-C for some parts of the app, but my Core Data stack is all Swift 2.2, Xcode 7.3.1 and I’m testing on iOS 9.3.1.</p><p>Users can choose between two sort orders: alphabetical, and distance. Additionally, users could filter venues by three categories and one of those categories had three subcategories. On top of the filtering, users can search by name, or by location, so that the name of the place they enter is geocoded. The venues are sorted by distance from that location, closest first.</p><p>I had the app working with JSON files and in memory store, but I was building up a lot of technical debt around dictionary keys and adding new features was difficult, so I decided to move over to Core Data. I’d kill two birds with one stone: Clean up the code, and adopt a framework which would offer killer performance if used correctly.</p><p>I started with a Core Data stack based on Apple’s default project setup and wrapped up the parts I needed in a separate object that I could pass around my app as needed. I wrote an NSOperation subclass to fetch and ingest my data from a server. That worked pretty flawlessly after a relatively short period of coding, so I was ready to re-implement my sorting, searching, and filtering. After that, I’d move on to new features.</p><p>I got table view indices working pretty quickly, because NSFetchedResultsController is designed for that. To boost performance and to group non-alphabetical titles together, I added a property to my model which contained a single sort character. That worked nicely as well.</p><p>The next part is to get the venues sorted by distance. It seems easy enough to do with NSSortDescriptor, except to use the basic sort descriptor, you have to use a property that’s stored in the Core Data SQLite database. Core Data doesn’t support using transient properties (such as a calculated CLLocation) with sort descriptors.</p><p>I could compute the distance and write to disk whenever the location updates, but the user might be moving while using my app, so I don’t know if that is such a good idea. Updating the results correctly requires updating the stored SQLite which in turn requires writing to disk and then fetching an update. Perhaps objects can be updated in memory, but not saved? How does NSFetchedResultsController handle this?</p><p>Thinking about it, I could probably write a second NSOperation whose only job would be to ensure that Core Data keeps my venues sorted properly. Again, this would require a read-write-read cycle but at least it would be in the background. Depending on how much latency there would be and how often the user moves, this might work. I started on this twice, but each time I realized that there’s another issue, and then stopped. That other issue is searching.</p><p>Searches on iOS generate a ton of garbage data as the user types, because of the instant results. Worse, I’m geo-coding the results, and then displaying the venues back based on the geo-coded result. Every search hitting disk is probably a very very bad idea. (To be fair, I wait for when I think a user has finished searching to fire off my geocoding request, so this might not be too bad, but it feels too heavy handed.)</p><p>I think what’s left is probably to do an in-memory sort. One downside to this approach is that it essentially ruins any memory benefit of Core Data’s faulting, because all of my venues need to be loaded into memory to organize them. I’m trying to figure out if there’s a better way to do this.</p><p>I’m beginning to think through a couple of ideas, and I’m posing them here for clarity:</p><ol><li>I wonder if there’s a way to flatten the latitude/longitude pair into a single value that’s independent of the user’s current location or search location. Then, when I get some other location, I can do the same reduction on that location and somehow simplify the sort. Vector math? Reduce?</li><li>Another option is pull out NSDictionaries instead of full objects. Just the coordinate pairs and the object IDs. That might make for a faster sort.</li><li>I just thought of something else. What if I saved all of the venues with a distance from some fixed coordinate (say CLLocation(latitude: 0.0, longitude: 0.0)) and then at runtime, calculate my user’s location (or search location) and compare the distances? That gets us most of the way there, but we’ll get venues that fall along a radius defined by our current distance from the precomputed point. Using that, and the signs of our latitude and longitude, it might be possible to filter, but probably not to sort.</li><li>I could sort in memory. This is what I was doing before, but it’s tricky to get right and stay performant, and I really wish I could get Core Data to help me out here. Additionally, because I’ve got the other filtering going on, it gets confusing to keep track of when to purge the geo-ordered cache, etc. This approach also runs into random crashes with NSFetchedResultsController but I think It’s because I’m being careless with leaving old sorting code lying around.</li></ol><p>One other consideration is that the rules of Core Data and NSManagedObject change slightly between Objective-C and Swift. If I were using Objective-C, I could probably get away with fancy property/method overrides that take advantage of the runtime. I can’t do in Swift.</p><p>This is one case where I’m probably better off with the power of Objective-C, but the brevity of Swift is too beautiful for me to give on it just yet. This feels like a map-reduce problem, but I’m not sure exactly where to start. I’m going to sleep on this and once I have a satisfactory solution, I’ll do my best to implement it.</p><p>This is probably part 1 of n, but I guess we’ll see.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7751ff24656f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hacking Pokemon Go]]></title>
            <link>https://medium.com/@bermaniastudios/hacking-pokemon-go-16491637c7d3?source=rss-ff4dee80c99f------2</link>
            <guid isPermaLink="false">https://medium.com/p/16491637c7d3</guid>
            <category><![CDATA[pokemon]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[iphone]]></category>
            <category><![CDATA[charle]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Moshe Berman]]></dc:creator>
            <pubDate>Thu, 07 Jul 2016 04:49:43 GMT</pubDate>
            <atom:updated>2016-07-07T05:04:10.409Z</atom:updated>
            <content:encoded><![CDATA[<p>Pokémon Go is finally out in the United States, and as a long time fan of the franchise, I downloaded it as quickly as I could. (I tried the New Zealand App Store this morning, but of course regional stores kept me waiting for a few more hours.)</p><p>After setting up my avatar and catching a Charmander, the first thing I did was fire up Charles and started poking around. (Not Poké-ing, poking.) Whenever a popular game comes out on iOS, I try to observe network traffic and inspect the app bundle to get an idea of what goes into the game. I didn’t find anything spectacular, but there were a few interesting bits. (I know nothing about Unity, so I might be amused at silliness.)</p><p>The app says it made of Unity in one of the splash screens, and the graphics certainly look great. The Google Maps logo is visible in a couple of places, including the Pokédex and the world map, and Charles logs show a couple of connections to Google Cloud APIs and an RPC heartbeat connection to pgorelease.nianticlabs.com. The responses are coming back as chunked gzip data from an nginx server. Pretty cool.</p><p>Unsurprisingly, there’s also an analytics SDK in there. (Two, actually!) They’re using Upsight’s SDK, and uploading information such as your screen dimensions, time zone, and some in game stats. It’s also grabbing carrier, connection type (cellular vs wifi) and a few other bits. Niantic is also tracking when you tap on the various in game buttons.</p><figure><img alt="A screenshot of Charles Proxy showing an upload to Upsight Analytics." src="https://cdn-images-1.medium.com/max/1024/0*7rjejeNazj50WiHV.png" /></figure><p>The other analytics library is Crittercism, but it’s a lot less “vocal” in the Charles logs, so if you don’t look for it, you’ll miss it.</p><p>I decided to let Charles run for a while, and I saw a few things going over the RPC connection…</p><p>When you tap on a Pokéstop, it shows up in the RPC heartbeat, along with a partially encoded URL, which points back to Google’s hosting API. Charles shows that these requests are the images for the Pokéstops.</p><p>Even though I was sitting on my couch the whole time, a few pokemon decided to spawn (in neighboring apartments, so I couldn’t get to them) and I could see them on the map. A Staryu appeared, so I looked and saw a URL in the RPC stream that looked like this:</p><blockquote>https://storage.googleapis.com/cloud_assets_pgorelease/bundles/ios/pm0120?generation={id}&amp;GoogleAccessId=...{more here}</blockquote><p>Notice the pm0120 bit? Staryu’s number is number 120 in the Pokédex. Copying the URL into a browser yields the data blob from the server, but again, I haven’t yet been able to open it. Trying to change the number fails, because there’s some bundle signing going on.</p><p>Eventually, the RPC connections start failing more and more frequently and the app finally crashed after about 50 minutes of sitting open connected to Charles. While watching the RPC stream and observing, I decided to look at a few other things…</p><p>Going directly to <a href="https://pgorelease.nianticlabs.com/plfe/7/rpc">the server</a> in a browser yields a webpage that says:</p><blockquote>Dude, this is the Player Frontend.</blockquote><p>The title of the page? Even funnier:</p><blockquote>Holoholo Player Frontend</blockquote><p>Once I was looking at the Niantic <a href="https://nianticlabs.com/jobs/">website</a>, I checked out the homepage. It notes that the company was founded by ex-Googlers, which explains the heavy use of Google as a backend.</p><p>At this point, I wasn’t able to do anything super interesting because of the intercepted data’s streaming format, but maybe someone will do something neat with this data some day. I am forward to playing the actual game tomorrow, despite a few subtle visual glitches.</p><h3>Sam Jarman on Twitter</h3><p>There are some really unpolished visual elements in #PokemonGO. Disappointing.</p><p>A few things jumped out at me almost immediately.</p><ol><li>On first launch, the location permissions prompt had a half baked permissions explanation.</li></ol><blockquote>In order to play the game.</blockquote><p>To their credit, Pokémon Go only uses location when the game is running, which is actually kind of interesting when you think about what they’re trying to do. (It’s pretty neat that they can augment reality with significant location updates and nothing more.)</p><ol><li>There’s a “next mission” hint which overlays the entire game, and gets in the way of menus and such. (It overs the Settings button in some screens, for example)</li><li>The status bar is dark even when displayed right next to white text. Seems like an oversight.</li></ol><p>&lt;</p><p>p&gt;Well, you know what the say about fixing bugs in early releases, right? Yes, you do. Shout it with me: “Gotta Catch ém All!”</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=16491637c7d3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Generating a PDF from a UIScrollView]]></title>
            <link>https://medium.com/@bermaniastudios/generating-a-pdf-from-a-uiscrollview-7dff2045bc31?source=rss-ff4dee80c99f------2</link>
            <guid isPermaLink="false">https://medium.com/p/7dff2045bc31</guid>
            <dc:creator><![CDATA[Moshe Berman]]></dc:creator>
            <pubDate>Sun, 10 Apr 2016 20:05:11 GMT</pubDate>
            <atom:updated>2016-04-11T01:05:16.018Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="A screenshot of an icon on the OS X desktop called UIScrollView.pdf." src="https://cdn-images-1.medium.com/proxy/0*Px_FGIFLP_p-HwVR.png" /></figure><p>PDF Generation of a UICollectionView.</p><p>There are plenty of situations where you might want to generate a PDF from a UIScrollView. If you search the internet, you’ll find lots of posts instructing you to change the frame of the scroll view to enclose all of its contents. This won’t work if you’re using AutoLayout. In any case, there’s a better way.</p><p>My first thought was to render the layer of the scroll view into some kind of Core Graphics context. That’s not wrong, but it’s tricky to get right. If you simply scroll, then render, scroll again, then render again, your Core Graphics viewport moves outside the visible area of the scroll view and gets clipped.</p><p>Note that for this example, I used some UIKit extension methods which don’t exist on OS X, but there are equivalent Core Graphics methods in for NSScrollView. You’ll see them called out with the UI prefix we all know and love. So, let’s get to it.</p><p>The first thing we need is the default origin and size of our pages. Since bounds always start at (0, 0) and the scroll view’s bounds give us the correct size for the visible area, we can just use that.</p><p>In the United States, a standard printed page is 8.5 inches by 11 inches, but when generating a PDF it’s simpler to keep the page size matching the visible area of the scroll view. We can let our printer software (such as the Preview app on OS X or the Printer app on iOS) do the scaling.</p><p>If we wanted to scale ourselves, we could multiply each of those numbers by 72, to get the number of points for each dimension. We would have to change how we generated the the pages below, so for simplicity, we’re going to stick to one page per screenful of content.</p><pre>let pageDimensions = scrollview.bounds</pre><p>Now we need to know how many pages we will need to fit our content. To get this, we divide our scroll views dimensions by the size of each page, in either direction. We also need to round up, so that the pages don’t get clipped:</p><pre>let pageSize = pageDimensions.size<br>    let totalSize = scrollview.contentSize<br><br>    let numberOfPagesThatFitHorizontally = Int(ceil(totalSize.width / pageSize.width))<br>    let numberOfPagesThatFitVertically = Int(ceil(totalSize.height / pageSize.height))</pre><p>Next, we have to set up a Core Graphics PDF context. First we create a backing store for the PDF data, then pass it and the page dimensions to Core Graphics.</p><pre>let outputData = NSMutableData()<br><br>    UIGraphicsBeginPDFContextToData(outputData, pageDimensions, nil)</pre><p>We could pass in some document information here, which mostly cover PDF metadata, including author name, creator name (our software) and a password to require when viewing the PDF file.</p><p>Also note that we can use UIGraphicsBeginPDFContextToFile() instead, which writes the PDF to a specified path. I haven’t played with it, so I don’t know if the data is written all at once, or as each page is closed.</p><p>The last thing we need to do before generating our PDF is to save some state. Since we will be scrolling, we will be changing the offsets of the scroll view. We also need to clear the content insets, so that our core graphics layer and our content offset match up.</p><pre>let savedContentOffset = scrollview.contentOffset<br>    let savedContentInset = scrollview.contentInset<br><br>    scrollview.contentInset = UIEdgeInsetsZero</pre><p>We don’t need to reset the content offset, because that happens implicitly, in the loop below:</p><pre>if let context = UIGraphicsGetCurrentContext()<br>    {<br>        for indexHorizontal in 0 ..&lt; numberOfPagesThatFitHorizontally<br>        {<br>            for indexVertical in 0 ..&lt; numberOfPagesThatFitVertically<br>            {<br><br>                UIGraphicsBeginPDFPage()<br><br>                let offsetHorizontal = CGFloat(indexHorizontal) * pageSize.width<br>                let offsetVertical = CGFloat(indexVertical) * pageSize.height<br><br>                scrollview.contentOffset = CGPointMake(offsetHorizontal, offsetVertical)<br>                CGContextTranslateCTM(context, -offsetHorizontal, -offsetVertical) <br><br>                scrollview.layer.renderInContext(context)<br>            }<br>        }<br>    }</pre><p>The magic happens when we change the contentOffset <em>and</em> translate the current transformation matrix (CTM) of the Core Graphics PDF context.</p><p>Consider that the viewport of the core graphics context is attached to the top of the scroll view’s content view and we need to push it in the opposite direction as we scroll. Further, anything not inside of the visible area of the scroll view is clipped, so scrolling will move the core graphics viewport out of the rendered area, producing empty pages.</p><p>To counter this, we scroll the next screenful into view, and adjust the core graphics context. Note that core graphics uses a coordinate system which has the y coordinate decreasing as we go from top to bottom. This is the opposite of UIKit (although it matches AppKit on OS X.)</p><p>There are faster ways to snapshot a view into a UIImage, but view.layer.renderInContext is the most straightforward way to do what it says on the tin: render a layer into a context.</p><p>Finally, we need to close the PDF context or we’ll get an empty PDF.</p><pre>UIGraphicsEndPDFContext()</pre><p>We also want to put things back the way we found them in the view hierarchy.</p><pre>scrollview.contentInset = savedContentInset<br>    scrollview.contentOffset = savedContentOffset</pre><p>By now, outputData contains a PDF document with screenfuls of data from the UIScrollView. This works with UIScrollView subclasses UITableView and UICollectionView as well.</p><p>You can get the sample project from on <a href="https://github.com/MosheBerman/ScrollViewSnapshotter">GitHub</a>. Take a look at the file called “<a href="https://github.com/MosheBerman/ScrollViewSnapshotter/blob/master/ScrollViewSnapshotter/ScrollViewSnapshotter.swift">ScrollViewSnapshotter.swift</a>” which contains all of the information in this post. Next time you need to snapshot a scroll view, don’t mess with the frame. Do it the right way!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7dff2045bc31" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Coloring The iOS UIScrollViewIndicators]]></title>
            <link>https://medium.com/@bermaniastudios/coloring-the-ios-uiscrollviewindicators-76a4651a54e7?source=rss-ff4dee80c99f------2</link>
            <guid isPermaLink="false">https://medium.com/p/76a4651a54e7</guid>
            <dc:creator><![CDATA[Moshe Berman]]></dc:creator>
            <pubDate>Mon, 28 Mar 2016 08:00:30 GMT</pubDate>
            <atom:updated>2016-03-28T16:33:33.539Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*f0aMUyPF621N_Lt2.png" /></figure><p>Scroll view w/ purple indicators.</p><p>On iOS, UIScrollView (and subclasses UITableView and UICollectionView) come with scroll indicators, which show your user where they are relative to the overall content size of the scroll view.</p><p>By default, you can set the scroll view indicators to either be black or white, like so:</p><pre>let tableView = UITableView() <br>tableView.indicatorStyle = UIScrollViewIndicatorStyle.Black<br>// Alternatively:<br>// tableView.indicatorStyle = UIScrollViewIndicatorStyle.White</pre><p>Here’s the secret, though: The scroll indicator is a UIImage. If you can grab it out of the view hierarchy, you can do fun things with it, such as tint it.</p><pre>func setScrollIndicatorColor(color: UIColor) {<br>        <br>        for view in self.tableView.subviews {<br>            if view.isKindOfClass(UIImageView.self),<br>                let imageView = view as? UIImageView,<br>                let image = imageView.image  {<br>                <br>                imageView.tintColor = color<br>                imageView.image = image.imageWithRenderingMode(.AlwaysTemplate)<br>            }<br>        }<br>        <br>        self.tableView.flashScrollIndicators()<br>    }</pre><p>There you have a custom scroll view. I’ve done this with App Store apps with no review issues, but your mileage may vary. A <a href="https://github.com/MosheBerman/CustomScrollIndicator">sample project</a> is available on GitHub.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=76a4651a54e7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Customizing Safari’s Pinned Tabs]]></title>
            <link>https://medium.com/@bermaniastudios/customizing-safari-s-pinned-tabs-56d912c7bdd5?source=rss-ff4dee80c99f------2</link>
            <guid isPermaLink="false">https://medium.com/p/56d912c7bdd5</guid>
            <dc:creator><![CDATA[Moshe Berman]]></dc:creator>
            <pubDate>Mon, 21 Mar 2016 08:45:30 GMT</pubDate>
            <atom:updated>2016-03-21T13:45:48.491Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*sXo8lzWEdAAWiUrg.png" /></figure><p>Ever pinned a few tabs in Safari and end up with a bunch of identical tabs which all had the same letter as the icon? I did. If you want to customize Safari’s pinned tab images, it’s pretty simple with the right tools. You’ll need a 32px image and a Property List editor, such as Xcode. Here’s how:</p><p>First, you need an image to put there. On retina systems, you want a 32 pixel by 32 pixel image in PNG format. On non-retina, you want 16 by 16 pixels.</p><p>Next, you need to know what to name the image. The tab icon template cache uses the MD5 hash function to map domain names to image files. A simple python script (<a href="https://gist.github.com/MosheBerman/8e06db9e34707a72883e">example here</a>) will give you the correct name. For example, the hash of “twitter.com” is 7905D1C4E12C54933A44D19FCD5F9356 so the file should be called 7905D1C4E12C54933A44D19FCD5F9356.png.</p><p>Once you’ve run the script, you need to put the image in ~/Library/Safari/Template Icons/.</p><p>For our final step, we need to tell Safari that the icon is there. Open up ~/Library/Safari/Template Icons/CacheSettings.plist and open up the section called TemplateIcons. You should see the website that you’ve pinned. Expand it, and change TemplateIconInCache to YES.</p><p>The last thing you’ll want to change is the color that the icon becomes when the pinned tab is active. Add a new key called TemplateIconThemeColor and change it to be an Array. Add three items, each with a color value between 0 and 1. The three values represent red, green, and blue, respectively.</p><p>Save the plist and restart Safari. Behold your beautiful new pinned tab icon.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*1QLL1eM2MBdJP-eY.png" /></figure><p>So now we know it works. If you’re curious to know how I worked this out, feel free to keep reading.</p><p>My first approach was to use the HTML inspector in Safari to edit the webpage before pinning it. The official way to add a custom icon to your website if you own it is to put a snippet of HTML into the page. I wondered if adding it to the page myself would do the trick. It did not. I had to dig deeper.</p><p>In order to tinker with the pinned tabs, I had to find out where Safari was storing them. If the data is saved even after Safari closes, it has to be written to your computer’s disk. The question was where.</p><p>I tried looking in ~/Library/Caches/ and ~/Library/Application Support/ but there was nothing useful. Then I found a tool called <a href="https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/fs_usage.1.html">fs_usage</a> which monitors whenever a program reads or writes to the file system. It can be filtered to spit out messages for a particular process instead of all of the programs that are running. (There are hundreds of programs or “processes” running at any given moment. Finding the right information would be impossible without a filter.).</p><p>To find the appropriate process to observe, I used Activity Monitor.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*YmJZ-KHP9miJl7qx.png" /></figure><p>Using Activity Monitor to find the process ID to use with fs_usage.</p><p>There were a whole lot of Safari related processes, and I wasn’t sure which one to observe, so I used the PIDs for Safari and Safari Database Storage. Next I opened Safari and pinned a tab. Boom! In the console, I saw a likely candidate: ~/Library/Safari/LastSession.plist.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*Iba9Gmiw4iaV1Nai.png" /></figure><p>Using fs_usage to find LastSession.plist</p><p>When I opened it, I saw something called SessionPinnedTabs which looked like what I wanted, but it was a red herring. There’s plenty of information stored there, including the URL that the tab contains, and even process IDs, but nothing about the icons.</p><p>I was close though. Another file I poked around inside of was called WebpageIcons.db. I thought that it might contain the images I wanted to change. I used an app called <a href="https://menial.co.uk/base/">Base</a> to open the database, but I couldn’t find anything related to pinned tabs.</p><p>Upon closer inspection, I found a subdirectory called Template Icons which looked like it was some kind of cache. It had a few small PNG images of sites I had previously pinned. There was also a file that I hadn’t noticed earlier. It was called CacheSettings.plist.</p><p>I opened it, and started poking around. The top section TemplateIconFallbackConfiguration, was really interesting. It had about 300 default icons in SVG format, sitting right there in the property list. Some entries had icons, while others referred to subdomains with the “AlternateHost” key.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*6yKmNrv9GemIuUQj.png" /></figure><p>The iCloud logo as an SVG.</p><p>My next strategy was to add SVG files into this section and hope Safari would do the right thing with them. The difficulty here was to produce an SVG that was in the right format for Safari to read out of the plist. I took a screenshot of AppAnnie.com and cut out Annie’s glasses with the wand tool. I saved it as a PNG and got to work trying to convert it.</p><p>To make sure Safari wasn’t generating garbage output based on garbage input, I copied the Apple logo, also stored in the CacheSettings.plist file and deleted some random points. The new output did indeed appear in Safari. So if I got an SVG to show, I would achieve my goal, but there had to be an easier way.</p><p>I tried to save an SVG in Photoshop CS6, but I learned the hard way that older versions of Photoshop don’t support SVG graphics at all. I downloaded a couple of old tools: <a href="https://www.imagemagick.org/">ImageMagick</a>, <a href="http://potrace.sourceforge.net/">potrace</a>, and <a href="http://autotrace.sourceforge.net/">autotrace</a>.</p><p>Photoshop CC 2015 could generate an SVG but not quite to spec. The headers and the contents of the SVG file didn’t match the ones used in Safari.</p><p>ImageMagick could do almost anything but it couldn’t create SVG files. Autotrace is really old and didn’t work. potrace could only work well with large images. That would mean that I’d have to scale down any SVG files that I made with it, and it wasn’t a process that would be easily repeated.</p><p>I managed to get Safari to show something in the pinned tab, but Safari wasn’t scaling anything, so the cached icon was a simple cutout of part of the larger image. Not what I wanted.</p><p>I realized that if I was going to make this work, I’d have to figure out how Safari was building the cache in Template Icons. I went back to the WebpageIcons.db database again but came up empty.</p><p>On a whim, I wrote a python script to convert a domain name to an MD5 hash and spit out the result. What if Safari hashes domain names to match to icons? I compared the result of running the script on “twitter.com” and the actual filename in the cache. It worked!</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*SbODXczioQL0GCGq.png" /></figure><p>Hashing Domain Names</p><p>This was my big breakthrough. Safari is running domain names through an MD5 hash and saving a system-dependent resolution black-and-white icon in the Template Icons directory. Now, all I had to do was modify the CacheSettings.plist and generate a tiny PNG image.</p><p>It’s possible that this process might change in the future, but for now, it seems possible to customize icons as described above. Your mileage may vary, but it’s pretty cool that this works.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=56d912c7bdd5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Economics Lessons from Get Famous!]]></title>
            <link>https://medium.com/@bermaniastudios/economics-lessons-from-get-famous-d42d80e0b101?source=rss-ff4dee80c99f------2</link>
            <guid isPermaLink="false">https://medium.com/p/d42d80e0b101</guid>
            <category><![CDATA[famous]]></category>
            <category><![CDATA[apps]]></category>
            <category><![CDATA[economics]]></category>
            <dc:creator><![CDATA[Moshe Berman]]></dc:creator>
            <pubDate>Tue, 01 Mar 2016 20:43:58 GMT</pubDate>
            <atom:updated>2016-03-02T01:44:00.192Z</atom:updated>
            <content:encoded><![CDATA[<p>[caption id=”attachment_2460&quot; align=”alignleft” width=”169&quot;]</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*KhtdiNPppbo55oqJ.jpg" /></figure><p>Piles of interest.[/caption]</p><p>What happens when an online trading card simulator goes viral, shuts down, and makes a return under a new name? You have an economics simulation with some very interesting lessons.</p><p>Back in January, a game called “Get Stolen” <a href="http://fortune.com/2016/01/08/get-stolen-app/">went viral</a>. It was pulled from the App Store just days after launch because <a href="http://www.gadgette.com/2016/01/14/stolen-app-shuts-down/">of criticism that</a> the game allowed players to “steal” and “own” people’s Twitter accounts.</p><p>The game returned to the App Store a few weeks later with a new name, “Get Famous!,” and a new metaphor to go along with it. Instead of stealing Twitter users, you become their biggest fan. This game just got a lot less offensive.</p><p>Like Get Stolen!, Get Famous requires a six letter promo code to play. I didn’t have one, so when I downloaded the app, I guessed. I was in, and ready to Get FAMOUS!</p><p>The currency symbol in this game is shaped like the outline of a heart. Whenever you see a heart, it means “dollars,” “pounds,” and “euros.” You start off with a small sum (about 1,500) of hearts to work with and a net worth of about 1,000 hearts.</p><p>Gameplay is fairly straightforward. You start out with a certain number of points, and each card has a point value. You can buy a card by touching the price tag in the corner of the card. Buying a card drives up its value and gives you an immediate bonus.</p><p>Each card carries some form of interest which accrues of over time. If you buy a card and you see a pile of hearts on it, tapping on the card will award you with the interest from that card.</p><p>When someone buys a card from you, the point value of the card also increases, and you net a small profit. The game displays cards in a Pinterest style waterfall, with 4 categories: FAM, FAMOUS, RISING, and NEW.</p><p>FAM is people you follow on Twitter. FAMOUS are the people valued at millions of hearts. RISING features people who have recently shot up in value. NEW is where the brand new accounts are. This gets really interesting when new accounts show up in the game, because bidding wars start.</p><p>While some might be trying to increase their own “revenue sources,” bidding a few times is a good way to earn some quick points. Also notable is that the bidding wars slow down at different when the card reaches different point values, depending on what other cards are visible on the screen. This is market comparison.</p><p>One way to look at Get Famous is to view it as a supply and demand simulation with a few caveats.</p><p>You have a limited number of people whom you can be the “biggest fan” of at once. In order to clear up spaces, you can dump (or “unfan”) people who aren’t bringing in interest. Oddly, that <em>increases</em> their point value as well.</p><p>Cards depreciate in value over time. If you buy someone for 145,426 hearts, their value will drop. There’s no relationship to number of times the card is bought and the amount it fades.</p><p>This brings me to the next point of confusion about this game. You have two scores, essentially. One is how much your card is worth, and the other is how many hearts you have “in the bank.” It’s unclear what the object of the game is. Your net worth is not related to your point balance.</p><p>I’m pretty sure that Get Famous is where everything is made up, and the points don’t matter, but even so, once I realized I was observing economic principles play out in near-realtime, it was pretty darn cool to watch.</p><p>[gallery ids=”2464,2461,2463,2460,2462&quot; type=”slideshow”]</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d42d80e0b101" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Notes from the tv Tech Talks NYC  ]]></title>
            <link>https://medium.com/@bermaniastudios/notes-from-the-tv-tech-talks-nyc-8ed7d63705ca?source=rss-ff4dee80c99f------2</link>
            <guid isPermaLink="false">https://medium.com/p/8ed7d63705ca</guid>
            <category><![CDATA[apple]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[apple-tv]]></category>
            <dc:creator><![CDATA[Moshe Berman]]></dc:creator>
            <pubDate>Wed, 13 Jan 2016 09:00:04 GMT</pubDate>
            <atom:updated>2016-01-13T14:02:38.444Z</atom:updated>
            <content:encoded><![CDATA[<h3>Notes from the tv Tech Talks NYC</h3><p>I had an exhilarating time at Apple’s Apple TV Tech Talks yesterday in New York City. Here are my notes from the sessions. (<a href="http://blog.mosheberman.com/wp-content/uploads/2016/01/AppleTVTechTalksNYC2015.pdf">Download</a>)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8ed7d63705ca" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[KosherCocoa is Being Upgraded]]></title>
            <link>https://medium.com/@bermaniastudios/koshercocoa-is-being-upgraded-8c154df686ec?source=rss-ff4dee80c99f------2</link>
            <guid isPermaLink="false">https://medium.com/p/8c154df686ec</guid>
            <dc:creator><![CDATA[Moshe Berman]]></dc:creator>
            <pubDate>Mon, 26 Nov 2012 21:32:04 GMT</pubDate>
            <atom:updated>2016-04-28T19:12:49.751Z</atom:updated>
            <content:encoded><![CDATA[<p><strong><em>Ed. Note:</em></strong><em> This post announced the retirement of an older version of KosherCocoa. KosherCocoa is still very much in development, and you can still find the latest version on GitHub.</em></p><p>Today, I’m officially retiring the KosherCocoa repository that’s on GitHub for two reasons.</p><ul><li>It’s somewhat incomplete, has a couple of notable bugs, and isn’t ARC ready.</li><li>A while ago, the demo project had been put up for sale on the App Store, against the license terms.</li></ul><p>When I can, I intend to publish the source for a static library, which will offer all of the functionality of KosherCocoa, with some changes. The new KosherCocoa will include unit tests, for my own sake, if nothing else. Also, I intend to include the features that were missing in the legacy repository. They’ve already been coded in a project of mine. Of course, the new repo will also support ARC. In the meantime, I’ve removed the demo UI and upgraded the project to ARC.</p><p>I don’t have a timetable on this project, and the legacy repository <a href="https://github.com/mosheBerman/KosherCocoa-legacy">still exists (sans the demo UI)</a>, but be aware that when the new library is ready, I might just let it fade away.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8c154df686ec" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>