Skip to main content

Posts

Showing posts with the label cocoa-touch

Convert image data to binary text for vcard

I need to include an image in a vcard file. The image is supposed to be in binary format. I create the image data as follows: NSData *imageData = UIImageJPEGRepresentation([UIImage imageNamed:@"Pic1"], 1.0); I have unsuccessfully tried encoding using the following 2 methods: vcardString = [vcardString stringByAppendingFormat:@"PHOTO;ENCODING=b;TYPE=JPEG:%@\n", [imageData base64EncodedString]]; AND vcardString = [vcardString stringByAppendingFormat:@"PHOTO;ENCODING=b;TYPE=JPEG:%@\n", [imageData description]]; Any advice on how to get the image data properly encoded to binary would be appreciated. Thanks

Recursively traverse object in Objective-C

I'm converting diverse JSON objects to structured objects and want to iterate over all the nodes to process each one hierarchically. JSON framework supports conversion to an NSDictionary, which I thought was unstructured. I want to recursively iterate through each item and pay respect to the structure. How would this be done with either a dictionary or generic NSOBject? Example: - (void) processParsedObject:(NSDictionary *)obj { if (atTheEndOfTheTail) { NSLog(@"Object description: %@\n\n", obj.description); } for (id object in obj) { [self processParsedObject:object]; } } Update: I asked the question more clearly here (with answer): Recursively traverse NSDictionary of unknown structure

Create a persistent store for Core Data

I did the tutorial on apples site, the Core Data tutorial for iOS and i did this tutorial about 3 times to see if i was mistaken, But when i finish the tutorial, it says that the app should work and be able to add Events to the table view, but when i press the + button, the app crashes and the console says: Cannot do save operation. There is no persistent store How could i fix this? I checked my code and i have everything!! Thanks in advance!

How to pass the Value from UITextField from one VC to a string in another VC?

I have googled for this and even tried searching in many forums, also tried Singleton,etc but each time my 2nd VC'c string is returning a NULL value. RETRIVALTVC is my VC in which i'm expecting for the Value and IRTViewController is my VC having the TextField. I have imported all the header files. This is my RetrivalTVC RetrivalTVC.h #import<UIKit> NSString *string; @property (nonatomic, copy) NSString *string; In RetrivalTVC.m when i tried to read the value of string its returning NULL - (void)viewDidLoad{ [self list]; } - (NSMutableArray *)list{ NSLog(@"Value of string: %@",string); } This is my IRTViewController IRTViewConroller.h @property (weak, nonatomic) IBOutlet UITextField *searchTrain; -(IBAction)search:(id)sender //Action when Button is Pressed IRTViewController.m -(IBAciton)search:(id)sender{ RetrivalTVC *retriv = [[RetrivalTVC alloc]init]; retriv.string = searchTrain.text; //Here when i used NSLog its returning the value Plea

UIImage Resize without loss of quality

Im looking for an external library (or a method using Apple frameworks that doesn't destroy the quality) which will let me scale down images. I have tried this 'simple-image-processing-library' but it only works for black and white - I don't know how to make it work for colour images. ( http://code.google.com/p/simple-iphone-image-processing/ ) I have tried Core Graphics, UIKit, the "trevor" ( http://vocaro.com/trevor/blog/2009/10/12/resize-a-uiimage-the-right-way/ ) method - which makes EXTREMELY blurry images and really I don't know what else I can do - I can't continue programming my app without getting at least half-decent image scaling working. I think interpolation is needed to get decent results. Given the recent advances in iOS, I really hope someone can help me. This isn't a problem that only I am having, lots of other people seem to have the same problem, so if someone could solve it here, I'm sure if would appreciated by a

Subclassing UISearchDisplayController For Abstraction

I have multiple UIViewController that have table views. I want these VCs to just handle UI stuff as they will all search the same database. I want to subclass UISearchDisplayController so I can have this subclass handle all the data and search stuff. The VC I am working with is a UIViewController with a UITableView and a UISearchDisplayController . I have it set and can check to display the initial, or the searched data into the table view by using if/else statements like: if (tableView == self.searchDisplayController.searchResultsTableView) % else... I want this custom subclass that I'm creating to handle the code that is executed in the self.searchDisplayController.searchResultsTableView statement so I can have some abstraction and can use this custom class with other VCs. Any ideas on how to continue with this? I think I need to override some methods in the UISearchDisplayController . EDIT: Actually I may be coming into this wrong. I have it stepup the way I l

Switching Between View Controllers Efficiently

In order to switch between views in my iOS app, I have been using Modal View Controllers. It works fine, but is this bad coding practice? Will it be detrimental to the memory usage of my app? In response to comments asking for more information, the views I am switching between are normal informational views. I am using three views to navigate through my app: Main View: Has buttons to navigate to specific informational views Info View: Has buttons to navigate to specific web pages for information Web View: Displays information through a UIWebview I have an improvised navigation bar at the top for navigating "back" and "home" do the main page. Overall, this is a web app with structure provided with menus in other views. I don't want to reveal what it does specifically (it's my idea), however this should be enough information to work with. I am currently switching between views like this: newViewController *newView = [[newViewController al

Delete UITableViewCell and ALL of that cell"s data

I have a UITableViewCell. I can add and subtract 1 from the cell's textLabel and I can also delete the cells. Here is my problem, Lets say i add 5 to the value of the textLabel . And this cell is at the 0 indexPath (The First cell in the table). When I delete this cell and there are now no longer any cells on the table, I add a new cell and this new cell automatically gets the same value as the cell that was just deleted. SO this new cell will have a value of 5 and i want the cell to have a value of 1 just like every cell should when it is added. This only happens when a cell is deleted and a new cell is added at that exact same indexPath. So my question is: do i have to delete this cells "memory" or "data" for this to be fixed? Thanks a bunch for the help! CellForRowAtIndexPath : - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; cell = [

How to programmatic segue from one UIViewController to another without Modal or Push?

If one UIViewController is a login screen, and the next one is the app's home screen, what would be the most optimal way to program the transition. I figure the modal segue class is inappropriate for this situation since ideally the transition to the home screen would be permanent, not temporary. But Push didn't make any sense either, since the login screen isn't a Navigation controller, and that isn't the functionality I'm looking for anyway. What would be the best way approach this specific case? Thanks!

Anti-aliasing lines when using CATransform3DRotate

I copied the code from the answer to How do I apply a perspective transform to a UIView? in order to achieve the following image. Note, however, the jagged lines separating the levels. Is there away to perform this kind of perspective transformation in a way that anti-aliases these jagged lines? Edit I've tried the solutions offered by DarkDust in the comments on this post. None seem to work. Here's my code: levelView = [[UIControl alloc] initWithFrame:CGRectMake(100, 60, 160, 230)]; [self addSubview:levelView]; levelView.transform = CGAffineTransformScale(self.transform, .8, .8); CALayer *layer = levelView.layer; //DarkDust's 2nd comment layer.borderWidth = 1; layer.borderColor = [[UIColor clearColor] CGColor]; CATransform3D rotationAndPerspectiveTransform = CATransform3DIdentity; rotationAndPerspectiveTransform.m34 = 1.0 / 1000; rotationAndPerspectiveTransform = CATransform3DRotate(rotationAndPerspectiveTransform, 45.0f * M_PI /