Xcode Static analysis and nulls

Leave a comment

return header
return (id __nonnull)header;

^(id  _Nullable result, NSError * _Nullable error)
^(SPTMessageTrack *track, NSError *error)

^(id data, NSError *error)
^(SPTMessageAccessToken *token, NSError *error)

fetchAccessTokenWithCallback:(void(^)(id data, NSError *error))block
fetchAccessTokenWithCallback:(void(^)(SPTMessageAccessToken *, NSError *))block


Xcode trouble shooting guide

Leave a comment

Here are a list if Xcode trouble shooting scenarios and what they usually mean.

Missing dependency target – file not found

Screen Shot 2017-03-22 at 8.21.55 AM.png

This usually means your subproject is foobar and you need to re-add it.

Screen Shot 2017-03-22 at 8.24.16 AM.png

Go here and follow the instruction on how to do that.


How to create a pull request against branch on master

1 Comment

Say someone has created a branch for you off of master, and they want to create Pull Requests (PRs) against it. Here’s how you do it.

Get on your fork (make sure sync’d and clean) and then do

git fetch remote branch
git checkout branch

So for example

git fetch upstream imessage
git checkout imessage

Screen Shot 2017-03-20 at 2.56.48 PM.png

This grabs the upstream branch, pulls it local, and then when you checkout a branch of the same name, it automatically sets it to the upstream branch you just checked out.

Now you can create a new branch off this one, do your work, and merge it back via GHE.

git checkout -b foo`

You are now ready to work

Screen Shot 2017-03-20 at 2.58.33 PM.png

How to write a git commit message

Leave a comment

Screen Shot 2017-03-17 at 8.22.42 AMScreen Shot 2017-03-17 at 8.23.13 AMScreen Shot 2017-03-17 at 8.23.29 AMhttps://chris.beams.io/posts/git-commit/

Setting end date instead of computing

Leave a comment

Instead of doing a lot of date and time comparisons, just set the end date of the thing you want.

For example instead of checking to see if a token expires in an hour like this

- (BOOL)hasExpired
    if (self.tokenExpirationDate == nil) {
        return YES;
    return [SPTMessageClockUtils oneHourHasPassedFrom:self.tokenExpirationDate];

Just set the expiration date on the object itself, and see if it is later than now like this.

- (BOOL)isValid
	return ([(NSDate *)[NSDate date] compare:self.expirationDate] == NSOrderedAscending);

This simplifies the computing and requires less coding to account for time checks and such.

Clock Pattern

Leave a comment

Here is an old pattern I used to use in C# whenever I wanted to freeze time in a test, and then verify that something happened after.

You define a Clock object where you can freeze and set the time. Then whenever you want a time in your system or in tests you simply ask it for it’s time.

DateTime now = Clock.CurrentTime();

Or in a test you can do something like this.

        public void When_updating_a_user()
                // Add user at this time
                DateTime currentTime = Clock.CurrentTime();

                // Update user 5 minutes later
                Clock.Add(new TimeSpan(0, 5, 0));
                DateTime newCurrentTime = Clock.CurrentTime();
                repository.UpdateUser(new User(randomUserName, true));

                User user = repository.FindBy(randomUserName);
                Assert.Equal(principalUserName, user.CreatedBy);
                Assert.Equal(currentTime, user.CreatedDate);
                Assert.Equal(principalUserName, user.ModifiedBy);
                Assert.Equal(newCurrentTime, user.ModifiedDate);


using System;

namespace src.utils
    public class Clock
        private static bool timeFrozen;
        private static DateTime currentTime;

        public static UnFreezeClock Freeze()
            DateTime now = DateTime.Now;
            return Freeze(new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, now.Second));

        public static UnFreezeClock Freeze(DateTime time)
            timeFrozen = true;
            currentTime = time;

            return new UnFreezeClock();

        public static DateTime CurrentTime()
            if (timeFrozen)
                return currentTime;
                return DateTime.Now;

        public static void Add(TimeSpan timeSpan)
            if (timeFrozen)
                currentTime = currentTime.Add(timeSpan);

        public static void Unfreeze()
            timeFrozen = false;
            currentTime = DateTime.Now;

How to create spherical gradient for title page Illustrator

Leave a comment

Say you want a nice soft glow in the background of your title page.

Screen Shot 2017-02-25 at 2.08.23 PM.png

Do this. Draw a square.

Screen Shot 2017-02-25 at 2.10.38 PM.png

Click Gradient from the Window menu

Screen Shot 2017-02-25 at 2.11.32 PM.png

Then click the gradient button to apply a gradient to your square. And then select ‘radial’ to make it spread out.

Screen Shot 2017-02-25 at 2.12.45 PM.png

Now the trick with making it spread out, it to press ‘g’ and then manually drag the end point of the gradient meter out beyond the square.

Screen Shot 2017-02-25 at 2.19.51 PM.png

Once you learn how to do that, you create create pretty much any gradient you want. Just grab the gradient tool, move it around, and try different things out.

Links that help

Trouble Shooting

If for some reason you find the gradient tool isn’t allowing you to change the gradient (i.e. pressing ‘g’ and then locking you out…toggle the fill stroke switch in the gradient window.

Screen Shot 2017-02-25 at 2.07.13 PM.png

Chances are you have stroke activated when what you really want is fill (or vice versa).


Older Entries

%d bloggers like this: