John’s Core Data Cheat sheet

It’s been a pretty long process for me to get working with Core Data. It’s no PHP thats for sure. In any case, below is a bunch different tasks that I was required to figure out for my development. Hopefully it helps.

Loading a specific object based on its value

    FLAppDelegate* appDelegate = [[UIApplication sharedApplication] delegate];
    NSManagedObjectContext* context = [appDelegate managedObjectContext];
    
    NSEntityDescription* enetityDescription = [NSEntityDescription entityForName:@"DataPointObject" inManagedObjectContext:context];
    NSFetchRequest* request = [[NSFetchRequest alloc] init];
    [request setEntity:enetityDescription];
    
    NSPredicate* predicate = [NSPredicate predicateWithFormat:@"(idValue = %@)", [NSNumber numberWithInteger:idValue]];
    [request setPredicate:predicate];
    NSArray* array = [context executeFetchRequest:request error:&error];

Check if Object Exists

    FLAppDelegate* appDelegate = [[UIApplication sharedApplication] delegate];
    NSManagedObjectContext* context = [appDelegate managedObjectContext];
    
    NSEntityDescription* enetityDescription = [NSEntityDescription entityForName:@"DataPointObject" inManagedObjectContext:context];
    NSFetchRequest* request = [[NSFetchRequest alloc] init];
    [request setEntity:enetityDescription];
    
    NSPredicate* predicate = [NSPredicate predicateWithFormat:@"(idValue = %@)", [NSNumber numberWithInteger:idValue]];
    [request setPredicate:predicate];

    NSError* error;
    NSInteger count = [context countForFetchRequest:request error:&error];
    if (count == NSNotFound || count == 0) {
        return NO;
    }

limit fetching request (ie load 100 objects)

    FLAppDelegate* appDelegate = [[UIApplication sharedApplication] delegate];
    NSManagedObjectContext* context = [appDelegate managedObjectContext];
    
    NSEntityDescription* enetityDescription = [NSEntityDescription entityForName:@"DataPointObject" inManagedObjectContext:context];
    NSFetchRequest* request = [[NSFetchRequest alloc] init];
    [request setEntity:enetityDescription];
    
    NSSortDescriptor* sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"idValue" ascending:NO];
    [request setSortDescriptors:@[sortDescriptor]];
    [request setFetchLimit:100];
    
    NSError* error;
    NSArray* array = [context executeFetchRequest:request error:&error];

Flappys Pipe – can you survive the birds?

So I never had a chance to download Flappy Bird and get on the craze of the pointless game. What I am able to do though is create my own pointless game with birds and pipes. So I did, and it’s called Flappys Pipe.

Flappys Pipe

Flappys Pipe

DOWNLOAD FROM APPLE APP STORE HERE

How does the Game work?

Enjoy running into the pipes while playing flappy bird? Neither did the pipe. So now it’s your turn to fight back by keeping alive. How do you do this? with one finger, or two, or a whole house hold of fingers to knock off the attacking flappy birds! Simple as a tap!

DOWNLOAD LINK

The future of iOS Programming is… not code block evaluation assignment

Come on, it’s 2014! Why isn’t code block evaluation assignment being used yet, as trends show it’s the future!

    UIButton* button = ({
        //initialize button with frame
        UIButton* button = [[UIButton alloc] initWithFrame:({
            CGRect frame = CGRectMake(10.0, 10.0, 200.0, 75.0);
            frame;
        })];
        //set button background color
        [button setBackgroundColor:({
            UIColor* color = [UIColor colorWithRed:1.0 green:1.0 blue:0.0 alpha:1.0];
            color;
        })];
        //set button title for state
        [button setTitle:({
            NSString* string = [NSString stringWithFormat:@"title words"];
            string;
        }) forState:({
            UIControlState state = UIControlStateNormal;
            state;
        })];
        //set selector
        [button addTarget:self action:({
            SEL select = @selector(method:);
            select;
        }) forControlEvents:({
            UIControlEvents event = UIControlEventTouchUpInside;
            event;
        })];
        //return button
        button;
    });
    [self.view addSubview:button];

whoa! whoa!

Or the exact results can be accomplished as such:

    UIButton* button = [[UIButton alloc] initWithFrame:CGRectMake(10.0, 10.0, 200.0, 75.0)];
    [button setBackgroundColor:[UIColor colorWithRed:1.0 green:1.0 blue:0.0 alpha:1.0]];
    [button setTitle:@"title words" forState:UIControlStateNormal];
    [button addTarget:self action:@selector(method:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button];

Now ask yourself, are trends really good to follow?

If you found this amusing, follow me on twitter @jdriselvato or up-vote this on stackOverflow

and yes, I did take this to the extreme.. a good clean example of doing this can be seen here.

My take on iOS App Store

I was discussing the App Store with a user on Stackoverflow and this was what I came up with.

I was asked the question, How many downloads did your free apps get in the first days?

I responded with,

Um, So my experience.. I created a personal app and put it up for .99 for the first two days. I only got 9 downloads in total. Then nothing the 3rd day. On the 4th day, I changed the price to free, and got 600 downloads (again this was 3 days after the initial release). Then from there it slowly died in about 2 weeks to 5-10 a day. But on my first update, I added in iAds and free download, which again shot up with about 500 downloads, and I made about 15$ from iAds click in about a month.

Then, Do you guys have any experience of “sale”-numbers with apps you put in for free at the first day?

Personally, it’s always better to put the game out for free the first few days. The reason being is because if it’s an awesome app, a lot of people will download it and share it because it’s free. This means you’re app will climb the charts much quicker. Once it’s on the top 100, that’s when it’s time time switch to a $0.99 app (because at that point it’s being publicly seen). No matter how awesome my app is, (if I don’t have in app purchases), I’m going to put my app out for free with ad)
then with the ability for 1.99 or 0.99 to purchase the ability to turn off ads.

Then the person commented questioning if they should do a drop price trick to get more users, I responded with:

I didn’t understand the market at the time. I thought if i put my app out for 0.99 i’ll make a million dollars. I made 7 dollars in 2 days and then zero dollars the 3rd day. That felts extremely disappointing considering the first few days and app is out, is usually the peak of revenue. When I drop it to free, i was doing that because I wasn’t making money and I really wanted people to play with my app. So I did and alot of people downloaded it.
But now, a year later, I get maybe about 10 downloads a week on a FREE app.
Which sucks. I don’t recommend, doing the set a price drop trick to get more users. Mine was a trial and error thing, not a way of doing things. but do what you want, like i said it’s a recommendation. A price drop might work for you. but nothing pisses a user off then see yesterday the app was $1.00 and today it’s free, and they just wasted a dollar away.

and

I always suggest the free app with iAPs or iAds. Always.

The person then stated, The reason on wanted to put a pricetag on it is to get more users…

and if you’re audience limited, then why limit it more with a price tag. a pricetag 9 times out 10, will drive most people away.

Well this was just my take on the App Store situation. I’m not sure if everyone agrees but this is the information I’ve formulated over my 3 years of experience developing iOS apps for companies and personally.

iOS 7: Custom NavigationView or NavigationViewController

This was a tricky one to figure out myself but this covers everything (back arrow color, back button color, title, title color, navigation bar color, transparency, etc).

custom navigation bar iOS 7

custom navigation bar iOS 7

    //set bar color
    [self.navigationController.navigationBar setBarTintColor:[UIColor colorWithRed:85.0/255.0 green:143.0/255.0 blue:220.0/255.0 alpha:1.0]];
    //optional, i don't want my bar to be translucent
    [self.navigationController.navigationBar setTranslucent:NO];
    //set title and title color
    [self.navigationItem setTitle:@"Title"];
    [self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObject:[UIColor whiteColor] forKey:UITextAttributeTextColor]];
    //set back button color
    [[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor], UITextAttributeTextColor,nil] forState:UIControlStateNormal];
    //set back button arrow color
    [self.navigationController.navigationBar setTintColor:[UIColor whiteColor]];

A small memory of my Gameboy and TLOZ Link’s awakening

I was listening to this:

and the gameplay showed link swimming, and I started thinking to myself, link swims? Then black and white gameplay started showing up in my head and the connections in my brain put together something I forgotten and lost so long ago. One of the first Gameboy games I owned as a six year old child was “The Legend of Zelda Link’s awakening”! This is amazing to me. As I sit writing this on my bed, I remember something really cool about this game. I used to play it non-stop, and to the point that the battery save feature stopped working (or this could have been because I washed plenty of gameboy games in my jeans). In any case, I remember telling my mom that this happened and we contacted nintendo (Based off the number that was on the easy to lose battery cover) and they let us send it in and they returned a new one one to me. (Now the more I think about this though, I remember sending off Zelda, but I remember receiving Pokemon Blue. My mind is remember a small folder with blue inside for some reason, regardless I remember Zelda wasn’t saving correctly and we sent it off).

One thing I would regret as an old man, is forgetting the amazing memories I had with my gameboy and my childhood. And since this is my blog, I am going to continue and explain how I bought a purple (see through) gameboy color at the age of six with my own money. When I was a kid, I was in the cub scouts. For whatever reason, my family (my mother especially) pushed me really hard one year to sell a lot of pop-corn as cub scouts do. Well it turned out I sold a record amount of pop-corn which in return I received a scholarship (that I have no clue how to get now that I’m in college) and personal spending money. Around the same time, Pokemon and the new Gameboy Color just came out and I remember going to this mall in pittsburgh pennsylvania to buy Pokemon Blue and the really cool looking purple see-through gameboy (thus Pokemon Blue was my first game, even though the same moment I bought Gex 3 – Deep Pocket Gecko). I remember the details of the stores outside and the location in the right back corner where Pokemon Blue was located and exactly where I grabbed it off the shelf. I was so excited to get own gameboy! At the time I didn’t understand money but I did pay for it with that money I earned, which looking back is pretty cool. Unfortunately, I have no clue where my Pokemon blue went to but I still have my beautiful original gameboy color. I play it everyone once in a while but mainly keep it for the memories.

As a quick side note, I used play so many hours of Pokemon with my friend Brian. Brian was really awesome to play with because he has a gameshark and spawned Mews for us. A few years after getting the Gameboy Color, I moved to North Carolina and lost touch with him. It’s been over 10 years since we’ve talked. If somehow you run into me on the internet, please hit me up! I would love to see how you are doing and catch up. I still have a photo of us I’ve kept :) along side my original Gameboy Color

How NASA world handle ETI (Alien) discovery

I am currently part of the space stack exchange beta forum that doesn’t have public access. A member on that forum asked an interesting question about how countries would handle Extraterrestrial intelligence (ETI) discovery. Well, I wrote a pretty awesome answer that I wanted to publish on my website here for the enjoyment of my non-existing fans. :D Also since I don’t want to write the biggest answer on an stack exchange site, i’ll be posting updates in find interesting on here. Anyway enjoy my comment below!

 


Great question Undo, I was interested so I did some digging myself. Apparent in August 21, 2011, NASA put together a report titled “Would Contact with Extraterrestrials Benefit or Harm Humanity? A Scenario Analysis.” that answers just that. Also found on Amazon for 1.99. This doesn’t cover how a country would respond but how NASA would handle several scenarios to the idea. I’m guessing since NASA is heavily funded by the United States and this document was published, the United States would obviously have regulations with NASA in mind if this were to occur.

In the first contact scenario NASA specifies that we should train our minds in the case that we become in contact with ETI (Extraterrestrial intelligence) so that "our minds grow accustomed to thinking about, identifying and analyzing specific scenarios and variations of them". They believe that by training our minds we will have a better capacity to analyze and respond to ETI contact. They break these scenarios into two parts intentionally or unintentionally harmful, which personally seems very science-fiction.

Being that this is a scientific paper i found it very inspiring that they talked about handling communication. Since our common form of communication is through specific wavelengths it’s impossible to know if we could ever be able to communicate with them. If an ETI is transmitting on an uncommon communication method it’s unknown how we could communicate.

The possibility also remains that ETI do not use electromagnetic radiation for communication but instead have discovered some other method (possibly something more efficient or effective) for exchanging information across astronomical distances.

Also it is noted that communication over vast distances might limit the ability for ETI to engage in warfare. Thus even if we do discover ETI the time it takes to communicate could be over 100s of years due to shear distance.

This difficulty in communicating across such vast distances also might limit the ability for ETI to engage in interstellar warfare for the simple reason that the communications problem renders such warfare too logistically difficult to coordinate

which starts the next interesting subject of

“Another implication of these long communication times across the galaxy is that ETI might become alerted to our presence without us realizing it”

Once ETI become alerted to our presence, it will take at least as many years for us to realize that they know we are here. During the intervening time, ETI can respond to our presence or prepare for contact in ways that we would have no knowledge of or influence on. Even if humanity can successfully exchange signals with ETI, there is no guarantee that the information will be successfully communicated. In order for information to be exchanged, it is also necessary that humans and ETI understand the contents of each others’ messages.

The answer to the concern with communication is that we would obviously communicate through mathematical conversation. Which is hinted to be our first few exchanges with ETI. They also talk about increasing the framework with METI to increase the probability of communication anytime a transmission is sent from earth.

In the same section of communication this paragraph stood out to me:

For example, we are almost guaranteed to lose in a fight between us and them, and there is a strong likelihood that such a loss would be so severe that we would cease to survive as a civilization. On the other hand, if ETI decide to use their superior abilities to help us, then they may be able to help solve many of our problems.

It’s obvious that depending on the situation how we handle a discovery depends on the nature of the ETI. I find it kind of sad that throughout this document that it’s a worry that ETI will be harmful to civilization. You would think that if we are searching and they are searching for life outside of their own, we would be peaceful not looking to destroy one another due to fear. In anycase, if the ETI are war-minded and more advance the odds of survival are small so we are prepared to loss but if they come with open-arms, we are ready to work hand and hand together to “solve many of our problems”. It would be pretty awesome to have ETIs come to use with cures to our diseases.

I don’t think people are interested in my analysis of the paper but I just wanted to give you a bit of an introduction of what’s inside. I haven’t read the entire thing yet and what I have covered has only been 8 pages in. NASA obviously has interest in how we should respond, they even go into the topics of Extraterrestrial ethics: Selfishness and universalism, Possible ETI heterogeneity, benefits, handling mere detection, how we would cooperate, and so much more. I am really excited to read the entire article. Great question again, I am glad I took the time to answer this. After I read it and find more interesting information i’ll post it in this answer if you are interested.

Last Minute WWDC Guesses

There is 9 minutes left until the Keynote at WWDC starts so i’ll take this time to give out my guesses.

1. As everyone is suspecting, a new interface for iOS. I am going to guess that the icons are going to be similar to that of the WWDC and the interface across all apps will be close to that app.

2. In text/email functionality. Something I haven’t seen much talk about but I believe Apple needs to add is in app texting and emailing functionality. As you have seen you can tweet from any app, via the drop down menu. Why can’t I text or email from any app? It’s annoying to be watching hulu or youtube from a device get a text and quit the app, stop listening, text and go back. Doesn’t Android do this already?

3. Obviously it wouldn’t be a keynote unless a new product is shown. I know this whole talk on iWatch has been on the horizon. Even Cook said he was interested in on body technology at D11, so I don’t want to guess iWatch as a stand alone product but maybe something that integrates with your already on you iDevice.

4. Tuned-In – this is something only I think have thought about. Apple has been on the hunt for iRadio type product. Recently, Tuned-in updated it’s interface and it’s pretty flat. It’s black and dark and the interface has been cleaned up pretty well (though I still think there is room for improvements). I’d love to see Apple teaming up with Tuned-in or even buying out Tuned-In for their future Radio product. Considering Tuned-ins’ fan base, it wouldn’t be a bad move.

That’s all I can think of and there is one minute left! LET GET GOING! WOOT!

Apple iOS 7: Apple still has it!

This morning I was plesently surprised to find out the WWDC app had a new interface! Check this out:

iOS 7 flat look picture!

Thanks to @yuize for this comparison image

 

If this new theme is any suggestion to what Apple has in store for iOS 7, I am super excited. Also apple doesn’t usually do something like this, unless it’s going to be big. And if you didn’t notice, there is a new replacement icon for photos, videos. Meaning live streaming? I have a really good feeling that Apple want’s all eyes (developers eyes) watching what they are going to do.

This is the first time in months that I actually feel good about Apple. Nice move with releasing this app today!

Will Apple impress the world again?! Let’s hope so!

iOS 7 Leaked icons

So apparently all these apple tech sites have evidence of the new iOS 7 flat icons… Even going into explaining what’s missing or changed. All from a blurry photo… Which in the world of amazing camera’s on everything, you would think blurry photos for leaks would be a thought of the past. Luckily a Designer, Surenix, took this awful photo and reproduced a mockup of what’s to come…

So.. Surenix makes a mock up of what might be a leak. What’s to say he didn’t create a mock up and then view the photo on his iPhone 5 (running iOS 6) and then guess what! Take a blurry photo.

Well I can do better… and it’s flat. And I just found that concept on dribbble.

iOS 7 interface/icons leaked