objective-c

Do you need to call willChangeValueForKey: and didChangeValueForKey: ?

I thought home-cooked @property setters were supposed to look like this: -(void) setFoo:(Foo *)newFoo { // Safeguards // ... [self willChangeValueForKey:@"foo"]; // Switcheroo // ... [self didChangeValueForKey:@"foo"]; } But I see a lot of code in blog posts by people who've been doing Cocoa a lot longer than I have, wh...

UILabels dont update on first load of the view.

I have UITableviews that set another views UILabels depending on the row selected. On the first selection of any row, the view loads with empty labels(nothing set), as soon as I navigate back and then when I choose a row after that it loads perfectly? Why arent the labels being set on the first selection? I have the following code ...

XMPP for exchanging game info between two iPad via Wi-Fi, good approach?

Hi all: Just got my iPad yesterday and I wanna start programming a distributed game between iPads for a little community across the globe, so no blue-tooth. I've heard of the XMPP protocol to enable data exchange between two PCs, such like this thread on SO Basically, the approach is a decentralized solution, once a valid connection ...

Encrypting streaming content onto persistent storage and decrypting it to the stream on iPhone

Hello fellow developers, My app "streams" content (fixed sized files, hence quotation marks) from an HTTP server into a local file. Then there is another component of the app that opens that same file and displays it (plays it). This is done for caching purposes, so that when the same file is requested next time, it will no longer need...

How to create a 2D NSArray or NSMutableArray in objective C?

Hi, everyone, I want to ask about the objective C question. I want to create a 2D NSArray or NSMutableArray in objective C. What should I do? The object stored in the array is NSString *. Thank you very mcuh. ...

UITableView works in 3.2 but no tableview methods are firing in 4.0 (simulator & device)

I just came across a situation where my implementation of a tableview is working in 3.2 but fails to fire any of the tableview methods in iOS 4. The view controller in question is defined as a UIViewController and is setup to adopt the UITableViewDataSource and UITableViewDelegate protocols, and I'm hooking the tableview up as the view's...

How to stack/z-position multiple UIElements (uilabel, uiimageview, etc) on top of each other?

I've got several UI elements on my screen (programmatically) and am in need of an efficient way to give each subview a z-index setting, so I can stack certain elements over others. Does anyone have a solution to this? ...

UITableView got slowly when dragging

Hello, I am new to iPhone development, and I can not understand the working principle of UITableView well. I customize the UITableViewCell, and the cell contains imageview. In addition, I initialize the cell reusable. However, when I drag the UITableView, it scrolls slowly. Then what should I do to process it? ...

How do I use CGContext to draw on top of an existing UIView?

I have a subclass of UIView in which I've added some subviews to in my initWithFrame method. I've added a background, amongst other things. I want to draw some shapes on top of these views (which happen to cover the entire screen). But, when I implement drawRect: to draw these shapes, they didn't show up. Upon removing the other subvie...

Core Data and UI Binding

My application builds its user interface and a core data model through code (no .xib .nib or .xcdatamodel files). I'm having trouble finding documentation on how to bind core data entity attributes (in an NSManagedObject) with the object properties of a UIView or UIViewControler such that the two are kept synchronized with each other. ...

UIWebView scrolling weirdness

Ok I have a UIWebView and a text field on a very simple viewcontroller (fresh project for testing). The webview opens up google.com on load and when the text field becomes first responder, I have the webview resizing so the content doesn't display underneath the keyboard. The resize is fine, but it appears the content of the control is s...

Accessing the value of a Preprocessor Macro definition

If I add a macro "FOO=bar" under GCC_PREPROCESSOR_DEFINITIONS (or Preprocessor Macros if you use XCode"), what would be the best way to access the value of "FOO"? Currently, I use the clumsy: #define MACRO_NAME(f) #f #define MACRO_VALUE(f) MACRO_NAME(f) #ifdef FOO NSLog(@"%s", MACRO_VALUE(FOO)); #else ...

How to pass the parameters from .m to another .m in objective C

Hi, everyone, I am writing the iPhone application and I would like to ask about the the passing parameters in objective C. I create 2 view controller. In the first one, I have a button, when a user press the button, it will call the -(IBAction) pressButton (user-defined), and after 5-6 second (have to process and retrieve the data in ...

Re-order an array

I have a list of bookmarks stored in NSUserDefaults. For each bookmark entry I retreive data from a sqlite database. I then create an array of these bookmarks. Each bookmark in the array is represented as a person object. How ca I re-order the array to sort by the persons first name? ...

iphone: Good practice for keeping my third-party libraries up-to-date?

Hi all, I want to ask about your practices to keep your third-party libraries up-to-date easily. In my iPhone project, I use quite a lot third-party libs (like TouchXML, JSON, RegexKit, YAJL, MGTwitterEngine...). Most of them is stored in GitHub and their version, especially MGTwitterEngine, change quite rapidly (because of adding new f...

How do I create a UIImageview from within a custom class?

I am an objective C newb and relative programming novice in general, so your patience is appreciated. Inside a View Based Application template I am pulling this code out of myNameViewController.m and trying to insert it into a custom class. Everything transitions fine except this: [self.view addSubview:myImage]; I gather this is now c...

how can i display image in UIscrollView which comes directly from parsing of web service?

Hi!i want to display image in UIImageView which is on the UIScrollView and using Touch Event the image should change from Right-to-Left and Left-to-Right also.The images are the result of NSXml parsing so what should i do please help me in this task.what should i do and if possible then show me with some example.Thanks in Advance..... ...

connecting all benifit of facebook to iphone

how can i get all test console of facebook like API test console.this one think AND another is but it is not woking help me here is code for getuser name - (void)getUserName { NSString* fql = @"select name from user where uid == 1234"; NSDictionary* params = [NSDictionary dictionaryWithObject:fql forKey:@"query"]; [[FBRe...

Sharing common method implementation between classes implementing the same protocol in Objective C

I have a protocol. MyProtocol.h: @protocol MyProtocol @property(nonatomic, retain) NSString* someString; - (void)doesSomethingWithSomeString; @end And 2 classes that implement the same protocol. For some reason the 2 classes cannot inherit from the same base class. E.g. 1 of them might need to inherit from NSManagedObject (Core D...

whats the proper way of passing an argument to NSTimer

Im using a basic timer that calls a method which is defined as below: - (void) refresh:(id)obj { if (obj == YES) doSomething; } I want to call this method from certain areas of my code and also from a timer [NSTimer scheduledTimerWithTimeInterval:refreshInterval target:self ...