objective-c

Understanding the line between Objective-C and Foundation, specifically NSString

In Objective-C, I can write: id pString = @"Hello, World."; and the compiler will instantiate an NSString without me needing to explicitly call a factory method. However, NSString is really just a Foundation class and thus presumably not part of the actual Objective-C language definition. So when I write @"String", how does the comp...

Memory Leak warning I can't solve

The static analyzer is showing up a leak in this block of code (specifically the link with the copy in it): - (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName { if ([elementName isEqualToString:@"item"]) { [elements setObject...

Severe memory problems with UIImagePickerController using Camera

I've noticed that when I load a UIImagePickerController and I take a picture with it, didReceiveMemoryWarning is called. Also, in Instruments, there is a significant memory leak (not by me, I swear!). I've heard that this is a problem with UIImagePickerController but, I'm not sure how to fix it. Here is my implementation of UIImagePicker...

iPhone: Can't affect UITextView content with initWithCoder

I'm trying to get a string displayed in my UITextView the moment the app is launched. I have a UIView and (obviously) a UITextView in my interface, and one outlet, myText, which is connected to the UITextView. It doesn't seem to be working and I can't say why.... Here is the code in question: MainView.h #import <UIKit/UIKit.h> #impo...

iPhone: Duplicate Symbol Error?

I got this error when i press build+debug: ld: duplicate symbol .objc_class_name_BlogTableItemCell in /Users/fabian/Development/Workspaces/iphone_experiments/xcode_build_output/MausLog.build/Debug-iphonesimulator/MausLog.build/Objects-normal/i386/BlogTableItemCell-3733583914888A7B.o and /Users/fabian/Development/Workspaces/iphone_exp...

how to add the content of the cell of table view in other view when clicked on cell in objective-c

I want to add the content of the cell of tableview in other view when i click on the tableview cell , how can i pass the values of the cell to other view. ...

How to restrict the class to access the methods of specified protocols in Objective-C?

When i'm trying to call protocolA methods, on an object of protocolB, i'm getting compiler warnings", but how would i restrict it to only methods of protocolB, i mean it shouldn't allow me to run the code, it has to give me an error ??? Is there any method to solve this problem in Objective-C? Example : // this is protocolA.h @protoco...

Alternative for templates in C++

I wrote code that looked like the following: template<typename CocoaWidget> class Widget : boost::noncopyable { private: CocoaWidget* mCocoaWidget; public: Widget() { mCocoaWidget = [[CocoaWidget alloc] init]; } // ... }; class Button : Widget<NSButton> { // ... }; But that doesn't work, because Mac Dev Center says:...

How to call a method through the object created by interface in Objective-C

Hi, I need to call a method through the object created by the interface ie id<MyProtocol>obj; Now i have created this obj in my main class where i am not implementing the methods of this protocol but i need to access the method which is already implemented in someother class.I am now calling the method as follows [obj load]; in ...

To display Headerview with image and labels in the viewcontroller

I am new to iphone development i have created one view controller and i used grouped table view. Now i want to display the header view in my viewcontroller with image and labels. please guide me and help me out in this problem. Thanks. ...

large scrollable "something" with TTStyledText in it

Hi, im searching for a solution of the following problem: i got a "larger" XHTML string that i want to display in an area that is scrollable. I already used TTStyledTextLabel for a small text-caption and it works pretty well. But now i want display it more like a UITextView that scrolls or a UIScrollView with my TTStyled Content in it...

Make a ViewController scrollable?

Hi, i was wondering how to make a ViewController (or TTViewController) scrollable, e.g. for long pages? My first try (make the frame bigger) doesnt work. CGRect appFrame = [UIScreen mainScreen].applicationFrame; CGRect frame = CGRectMake(0, 0, appFrame.size.width, appFrame.size.height + 200); self.view = [[[UIView alloc] initWithFrame...

Objective-C 'Robot' may not respond to '-nothingToDo'

Guys, I have two classes AppController and Robot. AppController.h #import <Cocoa/Cocoa.h> #import "Robot.h" @interface AppController : NSObject { Robot *myRobot; } - (IBAction)initPort:(id)sender; AppController.m #import "AppController.h" @implementation AppController - (IBAction)initPort:(id)sender { [myRobot nothingDo]; } @e...

iPhone Objective-C Simplest Way to get a stock quote

Hi guys Im wondering what is the simplest way to get the current price of a stock from say yahoo finance (or similar) in objective-C For the iPhone SDK. Simple is the key, I am looking for current price, and days movement. I havent had much luck finding an iPhone code example or library. regards ...

How to truncate an NSString based on the graphical width?

In UILabel there's functionality to truncate labels using different truncation techniques (UILineBreakMode). In NSString UIKit Additions there is a similar functionality for drawing strings. However, I found no way to access the actual truncated string. Is there any other way to get a truncated string based on the (graphical) width for ...

Gamekit and iPhone help

I have my app set up to send a custom level in a form of a array to another person during a p2p connection. The receiving device saves the array to file for later use. I set up gamekit in my application, it will successfully search and connect to another device without any problems. Though a problem arises when I send data to a device, t...

Encoding Large Object Graph Using NSKeyedArchiver Eats Memory

I'm using a NSKeyedArchiver to encode a big object graph (76295 objects.) It takes a lot of time but even worse the NSKeyedArchiver doesn't give back all its memory. After using the Leak check, the code doesn't appear to leak at all but for some reason the encoding doesn't give back all memory after it's done. Calling the encode method...

how to limit parsing in iphone?

I am new to iphone development .I want parse an image url from a xml file and display it in a RSS feed.There are three image url but i want to retrieve only one url and display it. <entry> <id>xxxxx</id> <title>xxx xxxx xxxx</title> <content>xxxxxxxxxxx</content> <media:group> <media:thumbnail url="http://tiger.jpg"/&gt; <media:thumbnai...

Is this a memory leak ?

I have something similar to this. initMyclass { if (self= [super init]) { classMember = [[NSMutableArray alloc] init]; } return self; } Instruments reports a leak there. I'm leaking memory there ? If not, xcode reports false memory leaks ? Thanks. ...

How do I copy objects into ivars for later use?

Objective c | xcode | iphone question Im building a model(data) class for a monetary transaction and have kind of a basic/noob question regarding pointers and object copying. The Transaction class I'm creating contains 4 or 5 ivars/properties that represent object type variables. now when I get the user entered data from the view contro...