Calculate StringLength in MacOS

This is the very simple example, in this program we will see how to calculate string length in MacOS.

Step 1: Create a Cocoa Application from Mac OS X . Give the application name “StringsLength”.

Step 2: Xcode automatically creates the directory structure and adds essential frameworks to it. You can explore the directory structure to check out the content of the directory.

Step 3: xpand the Other  Sources folder, then  you can see one file “main.m”. We need to make changes in this file.

Step 4: Open the main.m file and make the following changes in the file.

#import <Cocoa/Cocoa.h>

 int main(int argc, char *argv[])
 {
        char s1[250];
        char s2[250];
        printf("Enter string s1:\n");
        scanf("%s",&s1);
        printf("Enter string s2:\n");
        scanf("%s",&s2);
        if(strlen(s1) == strlen(s2))
        printf("Length of string s1 is equal to length of string s2\n");
        else if(strlen(s1) < strlen(s2))
        printf("Length of string s1 is less than length of string s2\n");
        else
        printf("Length of string s1 is greater than length of string s2\n");
               
        return NSApplicationMain(argc,  (const char **) argv);
}

Step 5: Now compile and run the example and see the output on the console.

You can Download SourceCode from here StringsLength

PageMove Using Touch

This is the PageMove application. In this application we will see, how to page move  using touch function.

Step 1: Create a Window base application using template. Give the application name  ”MovePage”.

Step 2: Xcode automatically creates the directory structure and adds essential frameworks to it. You can explore the directory structure to check out the content of the directory.

Step 3: xpand classes and notice Interface Builder created the  MovePageAppDelegate  class for you. Expand Resources and notice the template generated a separate nib, MainWindow.xib, for the “MovePage”.

Step 4: In this project we need add to two UIView class, so now select classes -> Add -> NewFile -> Cocoa Touch Class -> Objective-C class -> and select UIView from the Subclass of. After that select next and Give the file name “PageView”. Do it once again and and give the another file name “PDFView”.

Step 5: We need add QuartzCore.framework in the framework folder. Select frameworks -> Add -> Existing Frameworks -> and select QuartzCore.framework.

Step 6: Another thing we have add in the project, i.e one pdf file, so add pdf file in the Resource folder. Give the pdf name “monsooninfo.pdf”.

Step 7: Now open the PDFView.h file and add the NSUInteger, CGPDFDocumentRef class. So make the following changes.

#import <UIKit/UIKit.h>

@interface PDFView : UIView {

        NSUInteger PDFNumber;
        CGPDFDocumentRef pdf;
}

@property (assign) NSUInteger PDFNumber;

Step 8: Open the PDFView.m file and make the following changes.

(id)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
       
                CFURLRef pdfURL = CFBundleCopyResourceURL(CFBundleGetMainBundle(), CFSTR("monsooninfo.pdf"), NULL, NULL);
                pdf = CGPDFDocumentCreateWithURL((CFURLRef)pdfURL);
                CFRelease(pdfURL);
                self.PDFNumber = 1;
                self.backgroundColor = nil;
                self.opaque = NO;
                self.userInteractionEnabled = NO;
    }
    return self;
}

(void)drawRect:(CGRect)rect {
 
       
        CGContextRef context = UIGraphicsGetCurrentContext();
       
        CGPDFPageRef page = CGPDFDocumentGetPage(pdf, PDFNumber);
       
        CGContextTranslateCTM(context, 0, self.bounds.size.height);
        CGContextScaleCTM(context, 1, 1);
       

        CGContextSaveGState(context);
        CGAffineTransform pdfTransform = CGPDFPageGetDrawingTransform(page, kCGPDFMediaBox, self.bounds, 0, true);
        CGContextConcatCTM(context, pdfTransform);
        CGContextDrawPDFPage(context, page);
        CGContextRestoreGState(context);
}

Step 9: Open the PageView.h file and make the following changes.

#import <UIKit/UIKit.h>
#import "PDFView.h"

@interface PageView : UIView {
        NSUInteger PDFNumber;
       
@private
        PageView *View1;
        PageView *View2;
        PageView *View3;
       
}
@property (assign) NSUInteger PDFNumber;

Step 10: Now double click MainWindow.xib file and open it to the Interface Builder. First drag the view from the library and place it to the window. Select the view icon from the mainwindow and bring up IdentityInspector and select the pageView class (See the figure 1). Now save it, close it and go back to the Xcode.

Figure 1: Interface Builder connection

Step 11: Now open the PDFView.m file and make the following changes.

(void)awakeFromNib
{
       
  View1 = [[PDFView alloc] initWithFrame:self.bounds];
        View2 = [[PDFView alloc] initWithFrame:self.bounds];
       
        self.backgroundColor = [UIColor blackColor];
       
        [self addSubview:View3];
       
        View3.PDFNumber = 2;
        [self addSubview:View1];
}

(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
        lastPos = [[touches anyObject] locationInView:self];
}

CGPoint vectorBetweenPoints(CGPoint firstPoint, CGPoint secondPoint) {
        CGFloat xDifference = firstPoint.x secondPoint.x;
        CGFloat yDifference = firstPoint.y secondPoint.y;
       
        CGPoint result = CGPointMake(xDifference, yDifference);
       
        return result;
}

CGFloat distanceBetweenPoints(CGPoint firstPoint, CGPoint secondPoint) {
        CGFloat distance;
       
                CGFloat xDifferenceSquared = pow(firstPoint.x secondPoint.x, 2);
               
                CGFloat yDifferenceSquared = pow(firstPoint.y secondPoint.y, 2);
       
                distance = sqrt(xDifferenceSquared + yDifferenceSquared);
        return distance;
       
}
CGFloat angleBetweenCGPoints(CGPoint firstPoint, CGPoint secondPoint)
{
        CGPoint previousDifference = vectorBetweenPoints(firstPoint, secondPoint);
        CGFloat xDifferencePrevious = previousDifference.x;
       
        CGFloat previousDistance = distanceBetweenPoints(firstPoint,
                                                                                                         secondPoint);
        CGFloat previousRotation = acosf(xDifferencePrevious / previousDistance);
       
        return previousRotation;
}

(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
        CGPoint currentPos = [[touches anyObject] locationInView:self];
       
        fingerDelta = distanceBetweenPoints(currentPos, lastPos)/2;
       
        CGPoint fingerVector = vectorBetweenPoints(currentPos, lastPos);
       
       
       
        if ([[filter valueForKey:@"inputTime"] floatValue] < 0.9)
        {      
                [self bringSubviewToFront:View1];
                [filter release];
                filter = nil;
                filter = [[CAFilter filterWithType:kCAFilterPageCurl] retain];
                [filter setDefaults];
                [filter setValue:[NSNumber numberWithFloat:((NSUInteger)fingerDelta)/100.0] forKey:@"inputTime"];
               
                CGFloat _angleRad = angleBetweenCGPoints(currentPos, lastPos);
                CGFloat _angle = _angleRad*180/M_PI ;          
                if (_angle < 180 && _angle > 120)
                {
                        if (fingerVector.y > 0)
                                [filter setValue:[NSNumber numberWithFloat:_angleRad] forKey:@"inputAngle"];
                        else
                                [filter setValue:[NSNumber numberWithFloat:-_angleRad] forKey:@"inputAngle"];
                       
                        View1.layer.filters = [NSArray arrayWithObject:filter];
                }
        }
}

(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{      
        if ([[filter valueForKey:@"inputTime"] floatValue] > 0.7)
        {
                View1.PDFNumber ++;
                [View1 setNeedsDisplay];
               
                View3.PDFNumber ++;
                [View3 setNeedsDisplay];
               
                View1.layer.filters = nil;
               
                [filter setValue:[NSNumber numberWithFloat:0.0] forKey:@"inputTime"];
               
               
                CAFilter *previousFilter = [[CAFilter filterWithType:kCAFilterPageCurl] retain];
                [previousFilter setDefaults];
                [previousFilter setValue:[NSNumber numberWithFloat:0.91] forKey:@"inputTime"];
               
                [previousFilter setValue:[NSNumber numberWithFloat: M_PI] forKey:@"inputAngle"];
        }
        else
        {              
               
        }
}

Step 12: Now compile and run the application in the simulator. See the figure 2

Figure 2: Output of the Example.

You can Download SourceCode from here MovePage

New Readers Games

I’ve got another batch of readers games to post. I’ve not had enough time, but I wanted to get them listed so that people can give them a try and support the developers that have been working hard on them. Amgine Amgine is a fast-paced level-based iPhone and iPod puzzle game in which the player […]

Jailbreak Convention in London is World’s First

Jailbreak Convention MyGreatFest

Four years after iPhone Jailbreak took the world by storm, iOS users the world over will gather in London on September 17, 2011 for the world’s first Jailbreak convention. The jailbreak convention, dubbed MyGreatFest, will teach iOS users how to make the most of their Jailbroken iPhones, iPads and iPod touches.

Although a location and specific agenda have yet to be determined (Update: The convention will take place at the Old Truman Brewery), the jailbreak conference planners are already boasting that Jay Freeman aka Saurik, the founder of Cydia (i.e. the “App Store” of the Jailbreak world), will be in attendance. If the Jailbreak king will be there, then surely his devotees will follow.

The event website assures visitors that the Jailbreak convention will not be “just a bunch of tech geeks,” however I have my doubts. Really, who else but tech geeks would pay to go to a Jailbreak convention, especially one with such a ridiculous name?

Nevertheless, I have high hopes that the gathering will produce a new wave of Jailbreak innovations for us “normal” iPhone Jailbreak users.

I will not be attending, since I live a few thousand miles away and couldn’t bring myself to purchase a plane ticket to London for this, but I look forward to hearing more about the Jailbreak conference as it develops.

The iPhone as a device offers limitless potential, but it is hindered by the restrictions that Apple places on the software. Jailbreak’s appeal stems from the fact that it frees your iPhone and lets you use your device however you desire, rather than how Apple desires.

Will you be attending the world’s first Jailbreak convention?

Jailbreak Convention in London is World’s First is a post from Apple iPhone Review.

You Might Also Like…

  1. iPhone Jailbreak: Do You Jailbreak? [Reader Poll]
  2. iPhone 3GS Jailbreak
  3. iPhone Jailbreak: The Ultimate Guide


MoneyBook: Awesome Budgeting App for iPhone

MoneyBook for iPhone

After a recent unfortunate computer accident — word to the wise: never allow liquids near your laptop — I have been forced to go on a budget to recoup the costs of paying for repairs.

In the past, I have mostly lived paycheck-to-paycheck and spent most of the money I made, but now I have decided that it is time to get serious about saving money and paying off my recent debt.

In my search for the best way to document my purchases and keep a strict watch on my spending, I have discovered an iPhone app that has been tremendously helpful for managing my budget: MoneyBook ($2.99 in the App Store as of this writing).

MoneyBook for iPhone

The MoneyBook iPhone app lets you input transactions (both income and expenses) and categorize them so that you can keep track of what kinds of things you are spending your money on.

The app’s main page (pictured above) displays your salary (in my case, my budget for the month), your remaining funds, and a list of your top three expense categories.

Inputting New Transaction History

MoneyBook New Transaction

To input a transaction, simply touch “New Transaction” and enter the amount of your purchase. You may also select a category and write a note about your purchase. MoneyBook has a number of default categories, which you can modify in the settings.

Viewing Your Transactions

MoneyBook All Transactions

Moneybook lets you view your transaction history in several ways. You can view the current month’s transactions in the Transactions section, where your latest purchases are displayed by date, including the categories, notes and monetary amounts. These transaction items can also be edited.

The History section of the MoneyBook app displays your transactions in the same way, except that you can view your transaction history from past months.

MoneyBook Graph

The third and most interesting way to view your transactions is in the bar graph, which you can pull up by reorienting your iPhone on its side (landscape) when in the Transactions section. The bar graph shows you how much money you have spent per category in the current month. This is useful for narrowing down what types of things you spend the most money on.

You might find, for example, that you have been spending more money eating out than on groceries, and then you can adjust your budget accordingly.

Recurring Transactions

MoneyBook Recurring Transactions

Another great feature of the MoneyBook iPhone app is the ability to set recurring transactions, for example rent, cell phone bill and other regular monthly transactions.

Conclusion

I have tried other budgeting apps in the past, but they were either too simple or too complicated to use. MoneyBook, on the other hand, includes the right set of helpful features (modifiable categories, good summaries of my transaction history, recurring transactions, etc.) in an easy-to-use interface that has served me well in my recent attempt to better manage my finances.

Going forward, I plan to make my financial security a top priority, and the $3 MoneyBook app will be an essential tool for helping me attain that goal.

Have you used MoneyBook? What iPhone app do you use to help you stay on budget?

MoneyBook: Awesome Budgeting App for iPhone is a post from Apple iPhone Review.

You Might Also Like…

  1. iFitness iPhone App: An Exercise Log for Your iPhone [Review]
  2. iGorilla App is Good Model for Donation-Based Non-Profits [App Review]
  3. 3 Ways the Nook iPhone App Will Beat the Kindle iPhone App


TUAW TV Live: It’s the Air Club for Men

With all apologies to Dave Caolo, who first coined the term Air Club for Men, I had to highjack his awesome phrase for today’s TUAW TV Live. Given that most of the Mac App demos on today’s show will be done on an 11.6″ MacBook Air, I thought it fitting to use his jocularity as a title for the show today.

Some of the apps I’m planning to demonstrate during today’s live show include the new sleek and beautiful email app known as Sparrow, the wonderful graphic tool Pixelmator, Splashtop Remote, and possibly another new low-cost 3D graphic tool.

From your Mac or PC, go to the next page by clicking the Read More link at the bottom of this post, and you’ll find a livestream viewer and a chat tool. The chat tool allows you to participate by asking questions or making comments.

If you’re driving somewhere and would like to watch TUAW TV Live while you’re stuck in traffic, please don’t — keep your eyes on the road! However, if someone else is doing the driving, you can watch the show on your iPhone and join the chat by downloading the free Ustream Viewing Application. If you’re on an iPad, you should be able to use the Skyfire Browser to watch the stream, although you will not be able to participate in the chat.

We’ll start at about 5 PM ET, so if you’re seeing a prerecorded show, be sure to refresh your browser until you get the live stream.

Continue reading TUAW TV Live: It’s the Air Club for Men

TUAW TV Live: It’s the Air Club for Men originally appeared on TUAW on Wed, 16 Feb 2011 16:55:00 EST. Please see our terms for use of feeds.

Source | Permalink | Email this | Comments

Apple expected to have strong Q1 2011 shipments despite Intel’s glitch

Intel recently had a kerfuffle with its upcoming chipset lines, finding a defect in the 6 series and causing production of certain models to be delayed by as much as a few months. But if you’re waiting to buy a brand new MacBook Pro, don’t worry — because Apple is careful about when it upgrades its hardware, Digitimes says that shipments of new laptops designed in Cupertino won’t be delayed at all. The delay may affect other brands, simply because they play their profit margins a little closer to the bottom line, but because Apple’s prices already have so much profit built into them, it won’t have a problem even if it is affected by delays.

According to reports, shipments are up yet again anyway. Sources in the supply chain say that targets from January of this year were met according to expectations, and orders may be even higher than expected for the rest of the quarter. So there’s no shortage of good news along the supply chains for Apple.

Apple expected to have strong Q1 2011 shipments despite Intel’s glitch originally appeared on TUAW on Wed, 16 Feb 2011 16:30:00 EST. Please see our terms for use of feeds.

Source | Permalink | Email this | Comments

FX Photo Studio HD for iPad adds more filters and printing

FX Photo Studio HD, was already a comprehensive collection of photo filters for the iPad. Version 3.0, priced at US $2.99 for a limited time, adds 53 new effects bringing the total number of filters to 181. Effects can be combined and modified, and changes can be saved. If you have compatible printers, you can print directly from the app, and share photos via e-mail, Facebook, Twitter, Tumbler or Flickr. An innovative feature is the ability to share your creations with friends who are also running the app.

FX Photo Studio HD can save your photos in the photo album on your iPad, copy images to the clipboard, or even save to a document folder so you can move the images to your computer or other iOS device.

There are filters for just about any mood. Images can be blurred, turned into black and white or sepia. Textures can be added, and even lightning bolts can be generated. You can simulate tilt-shift lenses, to make parts of your photos look like miniatures.

Continue reading FX Photo Studio HD for iPad adds more filters and printing

FX Photo Studio HD for iPad adds more filters and printing originally appeared on TUAW on Wed, 16 Feb 2011 16:00:00 EST. Please see our terms for use of feeds.

Source | Permalink | Email this | Comments

Apple outlines differences between CDMA and GSM phones

Apple detailed the differences between the GSM and CDMA iPhone when it comes to voice calling and its associated features. The document confirms the Verizon iPhone is unable to hold a conference call with more than two attendees as well as put a call on hold. The Verizon iPhone can also use a manual method to toggle call forwarding, call waiting and caller ID instead of using the settings within iOS. Though not earth shattering, these shortcuts and, in certain cases, limitations may be helpful for folks with either version of the iPhone.

[Via 9to5 Mac and Macgasm]

Apple outlines differences between CDMA and GSM phones originally appeared on TUAW on Wed, 16 Feb 2011 15:30:00 EST. Please see our terms for use of feeds.

Source | Permalink | Email this | Comments