Search Results

Search found 528 results on 22 pages for 'viewcontroller'.

Page 6/22 | < Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >

  • How to notify ViewController on parse end with multiple ViewControllers using a single parser.

    - by objneodude
    Hello, I have created a RSS parser and 3 TableViews and it parses the RSS files fine but I don't know how to notify the TableViewController when parsing has ended so it can update the view. The TableViewController initiates the parser and the parsing of a feed. parser = [[RSSParser alloc] initWithURL:@"http://randomfeed.com"]; I can access the single feed items like [parser feedItems]; In parser.m i have implemented the delegate methods of NSXMLParser: - (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qualifiedName attributes:(NSDictionary *)attributeDict - (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string - (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName - (void)parserDidEndDocument:(NSXMLParser *)parser So how do i get parserDidEndDocument to notify my controllers so i can add the data to the tableview. Cheers from a obj-c beginner.

    Read the article

  • Why doesn’t ABPersonViewController show any properties besides the name?

    - by abrahamvegh
    For some reason, ABPersonViewController is unwilling to display any properties aside from the name, no matter what properties are set for it to display. I’m unable to use the AddressBookUI controllers to let a user select a contact to display, since my UI has custom requirements, otherwise I’d go that route (as Apple does in their sample project.) Here’s the code that doesn’t work — am I missing something? - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { // ABContact is of my own creation ABContact *contact = [self contactAtIndexPath: indexPath]; ABPersonViewController *viewController = [[ABPersonViewController alloc] init]; // This returns a valid ABRecordRef, as indicated by the fact that the // controller does display the name of this contact when it is loaded viewController.displayedPerson = contact.record; // Copied directly from Apple’s QuickContacts sample project NSArray *displayedItems = [NSArray arrayWithObjects:[NSNumber numberWithInt:kABPersonPhoneProperty], [NSNumber numberWithInt:kABPersonEmailProperty], [NSNumber numberWithInt:kABPersonBirthdayProperty], nil]; viewController.displayedProperties = displayedItems; [self.navigationController pushViewController: viewController animated: YES]; [viewController release]; }

    Read the article

  • OBJ-C: Call an instance of core-plot graph from separate view controller

    - by Kevin
    I'm using a view controller i.e. ViewController:UIViewController and have another class GraphViewController:UIViewController . How do I call an instance of GraphViewController and place it into my ViewController? I am currently trying to call the plot within my ViewController directly, but I want to make the graph modular so I don't have to copy code if I use the same graph again. ViewController has methods -(void) refreshGraph; //Inhereted Methods -(NSUInteger)numberOfRecordsForPlot:(CPPlot *)plot; -(NSNumber *)numberForPlot:(CPPlot *)plot field:(NSUInteger)fieldEnum recordIndex:(NSUInteger)index; How do I move these methods to a separate class and then call it to get the same plot in my ViewController? I am sure there must be a thread on this somewhere but I can't seem to find it.

    Read the article

  • No method found compiler warning

    - by Magic Bullet Dave
    I have create a class from a string, check it is valid and then check if it responds to a particular method. If it does then I call the method. It all works fine, except I get an annoying compiler warning: "warning: no '-setCurrentID:' method found". Am I doing something wrong here? Is there anyway to tell the compiler all is ok and stop it reporting a warning? The here is the code: // Create an instance of the class id viewController = [[NSClassFromString(class) alloc] init]; // Check the class supports the methods to set the row and section if ([viewController respondsToSelector:@selector(setCurrentID:)]) { [viewController setCurrentID:itemID]; } // Push the view controller onto the tab bar stack [self.navigationController pushViewController:viewController animated:YES]; [viewController release]; Cheers Dave

    Read the article

  • iOS5: Confusion with loadview and init and instance variables

    - by user743550
    I'm new to iOS5 and storyboarding. I noticed that if I declare an instance variables inside my viewcontroller .h file and set the values inside my init of .m file of my viewcontroller, whe the view of the viewcontroller is displayed, my instance variables show null inside viewDidLoad. In order for me to get myvariables, I'd need to do [self init] inside viewDidLoad. My questions are: @interface tableViewController : UITableViewController { NSMutableArray *myvariable; } @end @implementation tableViewController -(id)init { myvariable = [[NSMutableArray alloc]initWithObjects:@"Hi2",@"Yo2",@"whatsup2", nil]; } - (void)viewDidLoad { NSLog(@"%@",myvariable); // DISPLAYS NULL [super viewDidLoad]; } Why isn't my variables available in viewdidLoad when I declared and implemented in my .h and .m files? If that's the case, is viewDidLoad or viewWillAppear the common places to load the data for the viewcontroller? It looks like even if you instantiate a viewcontroller, the init function gets called but the viewDidLoad doesn't necessarily have the variables to be displayed. Where's the right place/methods to load the model(data) for my viewcontroller? Thanks in advance

    Read the article

  • Dynamically changing background color of a UIView

    - by EricM
    Hello- Here's my setup. I have a viewcontroller that I'm creating and adding as a subview. The viewcontroller presents some options that a user can chose from. The viewcontroller is being pushed in response to a "long press" gesture. Within the viewcontroller, I added a child UIView to group some other controls together so I can move them around the screen as a unit and, when they are displayed, center them on the location of the long press. Here is the code that instantiates the view controller, changes its location, and adds it as a subview: UserOptions *opts = [[UserOptions alloc] initWithNibName:@"UserOptions" bundle:nil]; [opts recenterOptions:location]; [self.view addSubview:opts.view]; That bit of code does create and push the viewcontroller, but the call to recenterOptions doesn't do anything. Here is that method: - (void) recenterOptions:(CGPoint)location { CGRect oldFrame = self.optionsView.frame; CGFloat newX = location.x; // + oldFrame.size.width / 2.0; CGFloat newY = location.y; // + oldFrame.size.height / 2.0; CGRect newFrame = CGRectMake(newX, newY, oldFrame.size.width, oldFrame.size.height); self.optionsView.frame = newFrame; } Note that self.optionsView is the child UIView that I added to the viewcontroller's nib. Does anyone know why I'm unable to change the location of the UIView? Regards, Eric

    Read the article

  • App Crashes Loading View Controllers

    - by golfromeo
    I have the following code in my AppDelegate.h file: @class mainViewController; @class AboutViewController; @interface iSearchAppDelegate : NSObject <UIApplicationDelegate> { UIWindow *window; mainViewController *viewController; AboutViewController *aboutController; UINavigationController *nav; } @property (nonatomic, retain) IBOutlet UIWindow *window; @property (nonatomic, retain) IBOutlet mainViewController *viewController; @property (nonatomic, retain) IBOutlet AboutViewController *aboutController; @property (nonatomic, retain) IBOutlet UINavigationController *nav; [...IBActions declared here...] @end Then, in my .m file: @implementation iSearchAppDelegate @synthesize window; @synthesize viewController, aboutController, settingsData, nav, engines; (void)applicationDidFinishLaunching:(UIApplication *)application { [window addSubview:nav.view]; [window addSubview:aboutController.view]; [window addSubview:viewController.view]; [window makeKeyAndVisible]; } -(IBAction)switchToHome{ [window bringSubviewToFront:viewController.view]; } -(IBAction)switchToSettings{ [window bringSubviewToFront:nav.view]; } -(IBAction)switchToAbout{ [window bringSubviewToFront:aboutController.view]; } - (void)dealloc { [viewController release]; [aboutController release]; [nav release]; [window release]; [super dealloc]; } @end Somehow, when I run the app, the main view presents itself fine... however, when I try to execute the actions to switch views, the app crashes with an EXC_BAD_ACCESS. Thanks for any help in advance.

    Read the article

  • Developing Spring Portlet for use inside Weblogic Portal / Webcenter Portal

    - by Murali Veligeti
    We need to understand the main difference between portlet workflow and servlet workflow.The main difference between portlet workflow and servlet workflow is that, the request to the portlet can have two distinct phases: 1) Action phase 2) Render phase. The Action phase is executed only once and is where any 'backend' changes or actions occur, such as making changes in a database. The Render phase then produces what is displayed to the user each time the display is refreshed. The critical point here is that for a single overall request, the action phase is executed only once, but the render phase may be executed multiple times. This provides a clean separation between the activities that modify the persistent state of your system and the activities that generate what is displayed to the user.The dual phases of portlet requests are one of the real strengths of the JSR-168 specification. For example, dynamic search results can be updated routinely on the display without the user explicitly re-running the search. Most other portlet MVC frameworks attempt to completely hide the two phases from the developer and make it look as much like traditional servlet development as possible - we think this approach removes one of the main benefits of using portlets. So, the separation of the two phases is preserved throughout the Spring Portlet MVC framework. The primary manifestation of this approach is that where the servlet version of the MVC classes will have one method that deals with the request, the portlet version of the MVC classes will have two methods that deal with the request: one for the action phase and one for the render phase. For example, where the servlet version of AbstractController has the handleRequestInternal(..) method, the portlet version of AbstractController has handleActionRequestInternal(..) and handleRenderRequestInternal(..) methods.The Spring Portlet Framework is designed around a DispatcherPortlet that dispatches requests to handlers, with configurable handler mappings and view resolution, just as the DispatcherServlet in the Spring Web Framework does.  Developing portlet.xml Let's start the sample development by creating the portlet.xml file in the /WebContent/WEB-INF/ folder as shown below: <?xml version="1.0" encoding="UTF-8"?> <portlet-app version="2.0" xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <portlet> <portlet-name>SpringPortletName</portlet-name> <portlet-class>org.springframework.web.portlet.DispatcherPortlet</portlet-class> <supports> <mime-type>text/html</mime-type> <portlet-mode>view</portlet-mode> </supports> <portlet-info> <title>SpringPortlet</title> </portlet-info> </portlet> </portlet-app> DispatcherPortlet is responsible for handling every client request. When it receives a request, it finds out which Controller class should be used for handling this request, and then it calls its handleActionRequest() or handleRenderRequest() method based on the request processing phase. The Controller class executes business logic and returns a View name that should be used for rendering markup to the user. The DispatcherPortlet then forwards control to that View for actual markup generation. As you can see, DispatcherPortlet is the central dispatcher for use within Spring Portlet MVC Framework. Note that your portlet application can define more than one DispatcherPortlet. If it does so, then each of these portlets operates its own namespace, loading its application context and handler mapping. The DispatcherPortlet is also responsible for loading application context (Spring configuration file) for this portlet. First, it tries to check the value of the configLocation portlet initialization parameter. If that parameter is not specified, it takes the portlet name (that is, the value of the <portlet-name> element), appends "-portlet.xml" to it, and tries to load that file from the /WEB-INF folder. In the portlet.xml file, we did not specify the configLocation initialization parameter, so let's create SpringPortletName-portlet.xml file in the next section. Developing SpringPortletName-portlet.xml Create the SpringPortletName-portlet.xml file in the /WebContent/WEB-INF folder of your application as shown below: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/> <property name="prefix" value="/jsp/"/> <property name="suffix" value=".jsp"/> </bean> <bean id="pointManager" class="com.wlp.spring.bo.internal.PointManagerImpl"> <property name="users"> <list> <ref bean="point1"/> <ref bean="point2"/> <ref bean="point3"/> <ref bean="point4"/> </list> </property> </bean> <bean id="point1" class="com.wlp.spring.bean.User"> <property name="name" value="Murali"/> <property name="points" value="6"/> </bean> <bean id="point2" class="com.wlp.spring.bean.User"> <property name="name" value="Sai"/> <property name="points" value="13"/> </bean> <bean id="point3" class="com.wlp.spring.bean.User"> <property name="name" value="Rama"/> <property name="points" value="43"/> </bean> <bean id="point4" class="com.wlp.spring.bean.User"> <property name="name" value="Krishna"/> <property name="points" value="23"/> </bean> <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource"> <property name="basename" value="messages"/> </bean> <bean name="/users.htm" id="userController" class="com.wlp.spring.controller.UserController"> <property name="pointManager" ref="pointManager"/> </bean> <bean name="/pointincrease.htm" id="pointIncreaseController" class="com.wlp.spring.controller.IncreasePointsFormController"> <property name="sessionForm" value="true"/> <property name="pointManager" ref="pointManager"/> <property name="commandName" value="pointIncrease"/> <property name="commandClass" value="com.wlp.spring.bean.PointIncrease"/> <property name="formView" value="pointincrease"/> <property name="successView" value="users"/> </bean> <bean id="parameterMappingInterceptor" class="org.springframework.web.portlet.handler.ParameterMappingInterceptor" /> <bean id="portletModeParameterHandlerMapping" class="org.springframework.web.portlet.handler.PortletModeParameterHandlerMapping"> <property name="order" value="1" /> <property name="interceptors"> <list> <ref bean="parameterMappingInterceptor" /> </list> </property> <property name="portletModeParameterMap"> <map> <entry key="view"> <map> <entry key="pointincrease"> <ref bean="pointIncreaseController" /> </entry> <entry key="users"> <ref bean="userController" /> </entry> </map> </entry> </map> </property> </bean> <bean id="portletModeHandlerMapping" class="org.springframework.web.portlet.handler.PortletModeHandlerMapping"> <property name="order" value="2" /> <property name="portletModeMap"> <map> <entry key="view"> <ref bean="userController" /> </entry> </map> </property> </bean> </beans> The SpringPortletName-portlet.xml file is an application context file for your MVC portlet. It has a couple of bean definitions: viewController. At this point, remember that the viewController bean definition points to the com.ibm.developerworks.springmvc.ViewController.java class. portletModeHandlerMapping. As we discussed in the last section, whenever DispatcherPortlet gets a client request, it tries to find a suitable Controller class for handling that request. That is where PortletModeHandlerMapping comes into the picture. The PortletModeHandlerMapping class is a simple implementation of the HandlerMapping interface and is used by DispatcherPortlet to find a suitable Controller for every request. The PortletModeHandlerMapping class uses Portlet mode for the current request to find a suitable Controller class to use for handling the request. The portletModeMap property of portletModeHandlerMapping bean is the place where we map the Portlet mode name against the Controller class. In the sample code, we show that viewController is responsible for handling View mode requests. Developing UserController.java In the preceding section, you learned that the viewController bean is responsible for handling all the View mode requests. Your next step is to create the UserController.java class as shown below: public class UserController extends AbstractController { private PointManager pointManager; public void handleActionRequest(ActionRequest request, ActionResponse response) throws Exception { } public ModelAndView handleRenderRequest(RenderRequest request, RenderResponse response) throws ServletException, IOException { String now = (new java.util.Date()).toString(); Map<String, Object> myModel = new HashMap<String, Object>(); myModel.put("now", now); myModel.put("users", this.pointManager.getUsers()); return new ModelAndView("users", "model", myModel); } public void setPointManager(PointManager pointManager) { this.pointManager = pointManager; } } Every controller class in Spring Portlet MVC Framework must implement the org.springframework.web. portlet.mvc.Controller interface directly or indirectly. To make things easier, Spring Framework provides AbstractController class, which is the default implementation of the Controller interface. As a developer, you should always extend your controller from either AbstractController or one of its more specific subclasses. Any implementation of the Controller class should be reusable, thread-safe, and capable of handling multiple requests throughout the lifecycle of the portlet. In the sample code, we create the ViewController class by extending it from AbstractController. Because we don't want to do any action processing in the HelloSpringPortletMVC portlet, we override only the handleRenderRequest() method of AbstractController. Now, the only thing that HelloWorldPortletMVC should do is render the markup of View.jsp to the user when it receives a user request to do so. To do that, return the object of ModelAndView with a value of view equal to View. Developing web.xml According to Portlet Specification 1.0, every portlet application is also a Servlet Specification 2.3-compliant Web application, and it needs a Web application deployment descriptor (that is, web.xml). Let’s create the web.xml file in the /WEB-INF/ folder as shown in listing 4. Follow these steps: Open the existing web.xml file located at /WebContent/WEB-INF/web.xml. Replace the contents of this file with the code as shown below: <servlet> <servlet-name>ViewRendererServlet</servlet-name> <servlet-class>org.springframework.web.servlet.ViewRendererServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>ViewRendererServlet</servlet-name> <url-pattern>/WEB-INF/servlet/view</url-pattern> </servlet-mapping> <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/applicationContext.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> The web.xml file for the sample portlet declares two things: ViewRendererServlet. The ViewRendererServlet is the bridge servlet for portlet support. During the render phase, DispatcherPortlet wraps PortletRequest into ServletRequest and forwards control to ViewRendererServlet for actual rendering. This process allows Spring Portlet MVC Framework to use the same View infrastructure as that of its servlet version, that is, Spring Web MVC Framework. ContextLoaderListener. The ContextLoaderListener class takes care of loading Web application context at the time of the Web application startup. The Web application context is shared by all the portlets in the portlet application. In case of duplicate bean definition, the bean definition in the portlet application context takes precedence over the Web application context. The ContextLoader class tries to read the value of the contextConfigLocation Web context parameter to find out the location of the context file. If the contextConfigLocation parameter is not set, then it uses the default value, which is /WEB-INF/applicationContext.xml, to load the context file. The Portlet Controller interface requires two methods that handle the two phases of a portlet request: the action request and the render request. The action phase should be capable of handling an action request and the render phase should be capable of handling a render request and returning an appropriate model and view. While the Controller interface is quite abstract, Spring Portlet MVC offers a lot of controllers that already contain a lot of the functionality you might need – most of these are very similar to controllers from Spring Web MVC. The Controller interface just defines the most common functionality required of every controller - handling an action request, handling a render request, and returning a model and a view. How rendering works As you know, when the user tries to access a page with PointSystemPortletMVC portlet on it or when the user performs some action on any other portlet on that page or tries to refresh that page, a render request is sent to the PointSystemPortletMVC portlet. In the sample code, because DispatcherPortlet is the main portlet class, Weblogic Portal / Webcenter Portal calls its render() method and then the following sequence of events occurs: The render() method of DispatcherPortlet calls the doDispatch() method, which in turn calls the doRender() method. After the doRenderService() method gets control, first it tries to find out the locale of the request by calling the PortletRequest.getLocale() method. This locale is used while making all the locale-related decisions for choices such as which resource bundle should be loaded or which JSP should be displayed to the user based on the locale. After that, the doRenderService() method starts iterating through all the HandlerMapping classes configured for this portlet, calling their getHandler() method to identify the appropriate Controller for handling this request. In the sample code, we have configured only PortletModeHandlerMapping as a HandlerMapping class. The PortletModeHandlerMapping class reads the value of the current portlet mode, and based on that, it finds out, the Controller class that should be used to handle this request. In the sample code, ViewController is configured to handle the View mode request so that the PortletModeHandlerMapping class returns the object of ViewController. After the object of ViewController is returned, the doRenderService() method calls its handleRenderRequestInternal() method. Implementation of the handleRenderRequestInternal() method in ViewController.java is very simple. It logs a message saying that it got control, and then it creates an instance of ModelAndView with a value equal to View and returns it to DispatcherPortlet. After control returns to doRenderService(), the next task is to figure out how to render View. For that, DispatcherPortlet starts iterating through all the ViewResolvers configured in your portlet application, calling their resolveViewName() method. In the sample code we have configured only one ViewResolver, InternalResourceViewResolver. When its resolveViewName() method is called with viewName, it tries to add /WEB-INF/jsp as a prefix to the view name and to add JSP as a suffix. And it checks if /WEB-INF/jsp/View.jsp exists. If it does exist, it returns the object of JstlView wrapping View.jsp. After control is returned to the doRenderService() method, it creates the object PortletRequestDispatcher, which points to /WEB-INF/servlet/view – that is, ViewRendererServlet. Then it sets the object of JstlView in the request and dispatches the request to ViewRendererServlet. After ViewRendererServlet gets control, it reads the JstlView object from the request attribute and creates another RequestDispatcher pointing to the /WEB-INF/jsp/View.jsp URL and passes control to it for actual markup generation. The markup generated by View.jsp is returned to user. At this point, you may question the need for ViewRendererServlet. Why can't DispatcherPortlet directly forward control to View.jsp? Adding ViewRendererServlet in between allows Spring Portlet MVC Framework to reuse the existing View infrastructure. You may appreciate this more when we discuss how easy it is to integrate Apache Tiles Framework with your Spring Portlet MVC Framework. The attached project SpringPortlet.zip should be used to import the project in to your OEPE Workspace. SpringPortlet_Jars.zip contains jar files required for the application. Project is written on Spring 2.5.  The same JSR 168 portlet should work on Webcenter Portal as well.  Downloads: Download WeblogicPotal Project which consists of Spring Portlet. Download Spring Jars In-addition to above you need to download Spring.jar (Spring2.5)

    Read the article

  • Pass Variables In Inheritance (Obj - C)

    - by Marmik Shah
    I working on a project in Obj-C where i have a base class (ViewController) and a Derived Class (MultiPlayer). Now i have declared certain variables and properties in the base class. My properties are getting accessed from the derived class but im not able to access the variables (int,char and bool type). I'm completely new to Obj-C so i have no clue whats wrong. I have used the data types which are used in C and C++. Is there some specific way to declare variables in Obj-C?? If so, How? Here are my files ViewController.h #import <UIKit/UIKit.h> @interface ViewController : UIViewController @property (weak,nonatomic) IBOutlet UIImageView* backGroungImage; @property (strong,nonatomic) IBOutlet UIImageView *blockView1; @property (strong,nonatomic) IBOutlet UIImageView *blockView2; @property (strong,nonatomic) IBOutlet UIImageView *blockView3; @property (strong,nonatomic) IBOutlet UIImageView *blockView4; @property (strong,nonatomic) IBOutlet UIImageView *blockView5; @property (strong,nonatomic) IBOutlet UIImageView *blockView6; @property (strong,nonatomic) IBOutlet UIImageView *blockView7; @property (strong,nonatomic) IBOutlet UIImageView *blockView8; @property (strong,nonatomic) IBOutlet UIImageView *blockView9; @property (strong,nonatomic) UIImage *x; @property (strong,nonatomic) UIImage *O; @property (strong,nonatomic) IBOutlet UIImageView* back1; @property (strong,nonatomic) IBOutlet UIImageView* back2; @end ViewController.m #import "ViewController.h" @interface ViewController () @end @implementation ViewController int chooseTheBackground = 0; int movesToDecideXorO = 0; int winningArrayX[3]; int winningArrayO[3]; int blocksTotal[9] = {8,3,4,1,5,9,6,7,2}; int checkIfContentInBlocks[9] = {0,0,0,0,0,0,0,0,0}; char determineContentInBlocks[9] = {' ',' ',' ',' ',' ',' ',' ',' ',' '}; bool player1Win = false; bool player2Win = false; bool playerWin = false; bool computerWin = false; - (void)viewDidLoad { [super viewDidLoad]; if(chooseTheBackground==0) { UIImage* backImage = [UIImage imageNamed:@"MainBack1.png"]; _backGroungImage.image=backImage; } if(chooseTheBackground==1) { UIImage* backImage = [UIImage imageNamed:@"MainBack2.png"]; _backGroungImage.image=backImage; } } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } @end I am not able to use the above declared variables in my derived classes!

    Read the article

  • Mixing Objective-C and C++: Game Loop Parts

    - by Peteyslatts
    I'm trying to write all of my game in C++ except for drawing and game loop timing. Those parts are going to be in Objective-C for iOS. Right now, I have ViewController handling the update cycle, but I want to create a GameModel class that ViewController could update. I want GameModel to be in C++. I know how to integrate these two classes. My problem is how to have these two parts interact with the drawing and image loading. GameModel will keep track of a list of children of type GameObject. These GameObjects update every frame, and then need to pass position and visibility data to whatever class or method will handle drawing. I feel like I'm answering my own question now (talking it out helps) but would it be a good idea to put all of the visible game objects into an array at the end of the update method, return it, and use that to update graphics inside ViewController?

    Read the article

  • Subclassing UINavigationBar ... how do I use it in UINavigationController?

    - by funkadelic
    Hi, I wanted to subclass UINavigationBar (to set a custom background image & text color) and use that for all the navigation bars in my app. Looking at the API docs for UINavigationController, it looks like navigationBar is read-only: @property(nonatomic, readonly) UINavigationBar *navigationBar Is there a way to actually use a custom UINavigationBar in my UIViewControllers? I know that other apps have done custom navigation bars, like flickr: Here is my UINavigationBar subclass: #import <UIKit/UIKit.h> @interface MyNavigationBar : UINavigationBar <UINavigationBarDelegate> { } @end the implementation #import "MyNavigationBar.h" @implementation MyNavigationBar - (id)initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { // Initialization code } return self; } - (void)drawRect:(CGRect)rect { // override the standard background with our own custom one UIImage *image = [[UIImage imageNamed:@"navigation_bar_bgd.png"] retain]; [image drawInRect:rect]; [image release]; } #pragma mark - #pragma mark UINavigationDelegate Methods - (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated{ // use the title of the passed in view controller NSString *title = [viewController title]; // create our own UILabel with custom color, text, etc UILabel *titleView = [[UILabel alloc] init]; [titleView setFont:[UIFont boldSystemFontOfSize:18]]; [titleView setTextColor:[UIColor blackColor]]; titleView.text = title; titleView.backgroundColor = [UIColor clearColor]; [titleView sizeToFit]; viewController.navigationItem.titleView = titleView; [titleView release]; viewController.navigationController.navigationBar.tintColor = [UIColor colorWithRed:0.1 green:0.2 blue:0.3 alpha:0.8]; } - (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated{ } - (void)dealloc { [super dealloc]; } @end I know that I can use a category to change the background image, but i still want to be able to set the text color of the navigation bar title @implementation UINavigationBar (CustomImage) - (void)drawRect:(CGRect)rect { UIImage *image = [UIImage imageNamed: @"navigation_bar_bgd.png"]; [image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)]; } @end any suggestions or other solutions? I basically want to create a light background and dark text like Flickr's app navigation bars

    Read the article

  • Adding UIViews with dynamic heights iphone

    - by Andy Jacobs
    in my viewcontroller's view i need to add a couple of custom UIView's, i do that in the loadView method so in my custom uiview's drawRect method i add a couple of UILabel's. in my viewcontroller's view i need to add all those custom UIView's underneath each other but i don't know what their height is sometimes 20px, 40px, 60px, depending on the outcome of the drawRect so when i init my custom UIView i give it a frame height of lets say 50.. but when the drawRect is done and it's only 20, 50 is too much so i need to adjust the frame height but how can i determine what's the visible height of the custom UIView and where can i catch it in my viewcontroller when the custom uiview has finished his drawRect method is there some kind of autoresize and where do i catch it in my viewcontroller, so i can position the custom uiview right under neath each other.

    Read the article

  • iphone menu navigation with buttons help requested

    - by David
    Hi, I'm trying to program an iphone app that will have several different (sub)apps. Ideally, I want to know how to make the main menu for this app look and behave like the iphone's own app menu, but I can't figure it out. If any one knows a package or library that does this, please let me know. Plan B is to mock one using UIButtons, and here is where I'm having problems. Basically, when I press a button that should push a new view, it calls the push method, but I still see the top view. in the app delegate, I have something like: AppViewController *viewController; App1ViewController *app1ViewController; UINavigationController *navController; and in didFinishLaunching method, something like: viewController = [ [ AppViewController alloc ] initWithAppDelegate: self ]; app1ViewController = [ [App1ViewController alloc ] initWithAppDelegate: self ]; navController = [ [ UINavigationController alloc ] initWithRootViewController:viewController]; [window addSubview:viewController.view]; and 2 methods -(void)app1{[ navController pushViewController: app1ViewController animated:YES ];} -(void)back{[ navController popViewControllerAnimated:YES ];} then I have 2 viewcontrollers in AppViewController.h @interface AppViewController : UIViewController { UINavigationController *navController; UIButton *appbtn1, *appbtn2, *appbtn3, *appbtn4; } -(id)initWithAppDelegate:(id)appDelegate; @end @interface App1ViewController : UIViewController { UITextView *textView; UINavigationController *navController; } -(id)initWithAppDelegate:(id)appDelegate; @end and define a loadView for each viewcontroller. However, when I press the app1 button and the app1 method gets called, it says the view hasa been pushed, but my view remains the buttons view, i.e. the root view. If I press the button again, it tells me I can't repush the app1view, the one I can't see. Any ideas? I can post the full code if that helps. Thank you for your time.

    Read the article

  • Passing Variables between views / view controllers

    - by Dan
    Hi I'm new to ObjectiveC / IPhoneSDK and I'm informally trying to study it on my own. What I'm basically trying to do is from one view there are 12 zodiac signs. When a user clicks one, it proceeds to the second view (with animation) and loads the name of the zodiac sign it clicked in a UILabel, that's it. Here are my codes: Lovescopes = 1st page Horoscopes = 2nd page Lovescopes4AppDelegate.h #import <UIKit/UIKit.h> #import "HoroscopesViewController.h" #import "Lovescopes4AppDelegate.h" @class Lovescopes4ViewController; @interface Lovescopes4AppDelegate : NSObject <UIApplicationDelegate> { UIWindow *window; Lovescopes4ViewController *viewController; HoroscopesViewController *horoscopesViewController; } -(void)loadHoroscope; -(void)loadMainPage; @property (nonatomic, retain) IBOutlet UIWindow *window; @property (nonatomic, retain) IBOutlet Lovescopes4ViewController *viewController; @property (nonatomic, retain) HoroscopesViewController *horoscopesViewController; @end Lovescopes4AppDelegate.m #import "Lovescopes4AppDelegate.h" #import "Lovescopes4ViewController.h" @implementation Lovescopes4AppDelegate @synthesize window; @synthesize viewController; @synthesize horoscopesViewController; -(void)loadHoroscope { HoroscopesViewController *aHoroscopeViewController = [[HoroscopesViewController alloc] initWithNibName:@"HoroscopesViewController" bundle:nil]; [self setHoroscopesViewController:aHoroscopeViewController]; [aHoroscopeViewController release]; [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:0.5]; [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:window cache:YES]; [viewController.view removeFromSuperview]; [self.window addSubview:[horoscopesViewController view]]; [UIView commitAnimations]; } -(void)loadMainPage { [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:0.5]; [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:window cache:NO]; [horoscopesViewController.view removeFromSuperview]; [self.window addSubview:[viewController view]]; [UIView commitAnimations]; [horoscopesViewController release]; horoscopesViewController = nil; } - (void)applicationDidFinishLaunching:(UIApplication *)application { // Override point for customization after app launch [window addSubview:viewController.view]; [window makeKeyAndVisible]; } - (void)dealloc { [viewController release]; [window release]; [super dealloc]; } @end Lovescopes4ViewController.h #import <UIKit/UIKit.h> #import "HoroscopesViewController.h" @interface Lovescopes4ViewController : UIViewController { HoroscopesViewController *hvc; } -(IBAction)loadAries; @property (nonatomic, retain) HoroscopesViewController *hvc; @end Lovescope4ViewController.m #import "Lovescopes4ViewController.h" #import "Lovescopes4AppDelegate.h" @implementation Lovescopes4ViewController @synthesize hvc; -(IBAction)loadAries { NSString *selected =@"Aries"; [hvc loadZodiac:selected]; Lovescopes4AppDelegate *mainDelegate = (Lovescopes4AppDelegate *) [[UIApplication sharedApplication] delegate]; [mainDelegate loadHoroscope]; } HoroscopesViewController.h #import <UIKit/UIKit.h> @interface HoroscopesViewController : UIViewController { IBOutlet UILabel *zodiacLabel; } -(void)loadZodiac:(id)zodiacSign; -(IBAction)back; @property (nonatomic, retain) IBOutlet UILabel *zodiacLabel; @end HoroscopesViewController.m #import "HoroscopesViewController.h" #import "Lovescopes4AppDelegate.h" @implementation HoroscopesViewController @synthesize zodiacLabel; /* // The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad. - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) { // Custom initialization } return self; } */ /* // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. - (void)viewDidLoad { [super viewDidLoad]; } */ /* // Override to allow orientations other than the default portrait orientation. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { // Return YES for supported orientations return (interfaceOrientation == UIInterfaceOrientationPortrait); } */ -(void)loadZodiac:(id)zodiacSign { zodiacLabel.text = [NSString stringWithFormat: @"%@", zodiacSign]; } -(IBAction)back { Lovescopes4AppDelegate *mainDelegate = (Lovescopes4AppDelegate *) [[UIApplication sharedApplication] delegate]; [mainDelegate loadMainPage]; }

    Read the article

  • NSString to NSURL objects

    - by user337844
    Hello, I have an array that I populated with my plist file, which looks something like this: <array> <string>http://www.apple.com</string> <string>http://www.google.com</string> <string>http://www.amazon.com</string> </array> So, I'm looking to convert these NSString objects to NSURL objects when I call them in my didSelectRowAtIndexPath method. Any ideas? This is what I have right now: - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSInteger row = [indexPath row]; if (self.viewController == nil) { TemplateViewController *details = [[TemplateViewController alloc] initWithNibName:@"TemplateViewController" bundle:nil]; self.viewController = details; [details release]; } NSString *tempURLString = [tieroneurlArray objectAtIndex:row]; NSURL *loadingUrl = [NSURL URLWithString:tempURLString]; [tieroneurlArray addObject:loadingUrl]; viewController.title = [NSString stringWithFormat:@"%@", [tieroneArray objectAtIndex:row]]; [self.viewController setTableURL:[tieroneurlArray objectAtIndex:row]]; TemplateAppAppDelegate *delegate = [[UIApplication sharedApplication] delegate]; [delegate.templateNavController pushViewController:viewController animated:YES]; } And this is how I load the array with the plist: - (void)viewDidLoad { [super viewDidLoad]; NSString *path = [[NSBundle mainBundle] pathForResource:@"tier1Names" ofType:@"plist"]; tieroneArray = [[NSMutableArray alloc] initWithContentsOfFile:path]; NSString *tableURL = [[NSBundle mainBundle] pathForResource:@"tier1URL" ofType:@"plist"]; tieroneurlArray = [[NSMutableArray alloc] initWithContentsOfFile:tableURL]; }

    Read the article

  • Swiping Images with Page Control in Iphone

    - by lakesh
    I am trying to make practice app where i can scroll images with page control. I am able to scroll images and able to include the page control. But the problem i face is i am not able to interlink the two. Meaning to say when I scroll the images, the page control is not affected and when i change the page control, the scrolling of the images is unaffected. I have referred to this: http://www.iosdevnotes.com/2011/03/uiscrollview-paging/ for the scrolling with page control. Viewcontroller.h #import <UIKit/UIKit.h> @interface ViewController : UIViewController <UIScrollViewDelegate>{ UIScrollView *scrollView; UIPageControl *pageControl; BOOL pageControlBeingUsed; } @property (nonatomic, retain) IBOutlet UIScrollView *scrollView; @property (nonatomic, retain) IBOutlet UIPageControl *pageControl; - (IBAction)changePage; @end Viewcontroller.m #import "ViewController.h" @interface ViewController () @end @implementation ViewController @synthesize scrollView,pageControl; - (void)viewDidLoad { [super viewDidLoad]; NSArray *images = [[NSArray alloc] initWithObjects:[UIImage imageNamed:@"1.jpeg"],[UIImage imageNamed:@"2.jpeg"],[UIImage imageNamed:@"3.jpeg" ], nil]; self.scrollView.contentSize = CGSizeMake(self.scrollView.frame.size.width * images.count, self.scrollView.frame.size.height); for (int i = 0; i < images.count; i++) { CGRect frame; frame.origin.x = self.scrollView.frame.size.width * i; frame.origin.y = 0; frame.size = self.scrollView.frame.size; UIImageView* imgView = [[UIImageView alloc] init]; imgView.image = [images objectAtIndex:i]; imgView.frame = frame; [scrollView addSubview:imgView]; } } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } - (void)viewDidUnload { // Release any retained subviews of the main view. // e.g. self.myOutlet = nil; self.scrollView = nil; } - (void)scrollViewDidScroll:(UIScrollView *)sender { // Update the page when more than 50% of the previous/next page is visible CGFloat pageWidth = self.scrollView.frame.size.width; int page = floor((self.scrollView.contentOffset.x - pageWidth / 2) / pageWidth) + 1; self.pageControl.currentPage = page; } - (IBAction)changePage{ // update the scroll view to the appropriate page CGRect frame; frame.origin.x = self.scrollView.frame.size.width * self.pageControl.currentPage; frame.origin.y = 0; frame.size = self.scrollView.frame.size; [self.scrollView scrollRectToVisible:frame animated:YES]; pageControlBeingUsed = YES; } - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView { pageControlBeingUsed = NO; } - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { pageControlBeingUsed = NO; } @end Need some guidance on this... Thanks..

    Read the article

  • [iPhone] presentModalViewController not working

    - by ryyst
    Hi, here's my code: ViewController *vc = [[ViewController alloc] initWithNibName:@"TableView" bundle:nil]; [self.navigationController presentModalViewController:vc animated:YES]; //[self setView:[vc view]]; If I call it, nothing happens. However, if I change it to: ViewController *vc = [[ViewController alloc] initWithNibName:@"TableView" bundle:nil]; //[self.navigationController presentModalViewController:vc animated:YES]; [self setView:[vc view]]; The view appears just fine (without the transition, of course). What am I doing wrong? Is there anything special you have to take care of when initializing the view controller? I tried to copy as much as possible from Apple's examples, but I can't get this to work... Thanks for any input! -- Ry

    Read the article

  • UISplitViewController Cannot Change the Master View Controller?

    - by Nex
    I am trying to change the master view controller (that appears in the popover in portrait, and on the left side in landscape) in a UISplitViewController. I'd like to switch between the master view controller being one of two different UIViewControllers (depending on an action taken elsewhere in my application). I am using the following: mySplitViewController.viewControllers = [NSArray arrayWithObjects:newMasterController, detailController, nil]; This correctly changes the master viewcontroller as you would expect in landscape mode. However it does not seem to change the viewcontroller used for the popover in portrait mode. I notice that the barbuttonitem to show this master view controller is just calling showMasterInPopover: on the splitviewcontroller, and so would expect it to work in portrait mode as well, but it does not. In fact, I can set the master view controller, see the new viewController correctly in landscape mode, rotate back to portrait, and the viewcontroller used in the popover is still the old one. Is this a bug?

    Read the article

  • Objective-C: How to access methods in other classes

    - by Adam
    I have what I know is a simple question, but after many searches in books and on the Internet, I can't seem to come up with a solution. I have a standard iPhone project that contains, among other things, a ViewController. My app works just fine at this point. I now want to create a generic class (extending NSObject) that will have some basic utility methods. Let's call this class Util.m (along with the associated .h file). I create the Util class (and .h file) in my project, and now I want to access the methods contained in that class class from my ViewController. Here's an example of a simple version of Util.h #import <Foundation/Foundation.h> @interface Util : NSObject { } - (void)myMethod; @end Then the Util.m file would look something like this: #import "Util.h" @implementation Util - (void)myMethod { NSLog(@"myMethod Called"); } @end Now that my Util class is created, I want to call the "myMethod" method from my ViewController. In my ViewController's .h file, I do the following: #import "Util.h" @interface MyViewController : UIViewController { Util *utils; } @property (assign) Util *utils; @end Finally, in the ViewController.m, I do the following: #import "Util.h" @implementation MyViewController @synthesize utils; - (void)viewDidLoad { [super viewDidLoad]; utils.myMethod; //this doesn't work [utils myMethod]; //this doesn't work either NSLog(@"utils = %@", utils); //in the console, this prints "utils = (null)" } What am I doing wrong? I'd like to not only be able to directly reference other classes/methods in a simple util class like this, but I'd also like to directly reference other ViewControllers and their properties and methods as well. I'm stumped! Please Help.

    Read the article

  • How to access the parent view controller?

    - by tarnfeld
    I am using this code to push a view controller in ViewControllerA: DatePickerViewController *viewController = [[DatePickerViewController alloc] initWithNibName:@"DatePickerViewController" bundle:nil]; NSMutableArray *info = [[NSMutableArray alloc] initWithObjects:@"Exam Duration",nil]; [viewController setInfo:info]; [info release]; [self.navigationController pushViewController:viewController animated:YES]; [viewController release]; In the DatePickerViewController that is slid in, it has a text field. In ViewControllerA how can I get the value of this text field once the viewWillDisappear method is fired, it's to save data.

    Read the article

  • Why does my iOS app crash when trying presentModalViewController?

    - by user555807
    I've been banging my head against this all day, it seems like something simple but I can't figure it out. I've got an iOS app that I created using the "View-based Application" template in XCode. Here is essentially the code I have: AppDelegate.h: #import <UIKit/UIKit.h> @interface AppDelegate : NSObject <UIApplicationDelegate> { UIWindow *window; MainViewController *viewController; } @property (nonatomic, retain) IBOutlet UIWindow *window; @property (nonatomic, retain) IBOutlet MainViewController *viewController; @end AppDelegate.m: #import "AppDelegate.h" #import "MainViewController.h" @implementation AppDelegate @synthesize window, viewController; - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [self.window addSubview:viewController.view]; [self.window makeKeyAndVisible]; return YES; } - (void)dealloc { [viewController release]; [window release]; [super dealloc]; } @end MainViewController.h: #import <UIKit/UIKit.h> @interface MainViewController : UIViewController { } -(IBAction) button:(id)sender; @end MainViewController.m: #import "MainViewController.h" #import "ModalViewController.h" @implementation MainViewController ... -(IBAction) button:(id)sender { ModalViewController *mvc = [[[ModalViewController alloc] initWithNibName:NSStringFromClass([ModalViewController class]) bundle:nil] autorelease]; [self presentModalViewController:mvc animated:YES]; } @end There's nothing of interest in the ModalViewController. So the modal view should display when the button is pressed. When I press the button, it hangs for a second then crashes back to the home screen with no error message. I am stumped, please show me what I'm doing wrong!

    Read the article

  • Testing if a UI element is hidden in an OCUnit test

    - by Logan Serman
    I have a button that is hidden under certain circumstances that I wish to test. The button is hidden with [theButton setHidden: YES] in the viewDidLoad method if it is appropriate. For simplicity, lets say that the button is hidden when the buttonIsHidden property is set to true in the view controller. Right now I am trying the following: self.viewController = [[ViewController alloc] init]; self.viewController.buttonIsHidden = YES; [self.viewController loadView]; UIButton *theButton = [...] // function I wrote to retrieve the button based on it's touch up inside action if (theButton) { NSLog(@"%c", theButton.hidden); return (theButton.hidden == true) } return NO; It looks like the hidden property is not what it should be, the NSLog lines from the above code are blank. But, if I output another property like the height, it outputs the correct value so I know it is getting the right button. How do I access the hidden property of the button in this case?

    Read the article

  • Clicking the TableView leads you to the another View

    - by lakesh
    I am a newbie to iPhone development. I have already created an UITableView. I have wired everything up and included the delegate and datasource. However, instead of adding a detail view accessory by using UITableViewCellAccessoryDetailClosureButton, I would like to click the UITableViewCell and it should lead to another view with more details about the UITableViewCell. My view controller looks like this: ViewController.h #import <UIKit/UIKit.h> @interface ViewController : UIViewController<UITableViewDataSource,UITableViewDelegate>{ NSArray *tableItems; NSArray *images; } @property (nonatomic,retain) NSArray *tableItems; @property (nonatomic,retain) NSArray *images; @end ViewController.m #import "ViewController.h" #import <QuartzCore/QuartzCore.h> @interface ViewController () @end @implementation ViewController @synthesize tableItems,images; - (void)viewDidLoad { [super viewDidLoad]; tableItems = [[NSArray alloc] initWithObjects:@"Item1",@"Item2",@"Item3",nil]; images = [[NSArray alloc] initWithObjects:[UIImage imageNamed:@"clock.png"],[UIImage imageNamed:@"eye.png"],[UIImage imageNamed:@"target.png"],nil]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return tableItems.count; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ //Step 1:Check whether if we can reuse a cell UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"]; //If there are no new cells to reuse,create a new one if(cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:(UITableViewCellStyleDefault) reuseIdentifier:@"cell"]; UIView *v = [[UIView alloc] init]; v.backgroundColor = [UIColor redColor]; cell.selectedBackgroundView = v; //changing the radius of the corners //cell.layer.cornerRadius = 10; } //Set the image in the row cell.imageView.image = [images objectAtIndex:indexPath.row]; //Step 3: Set the cell text content cell.textLabel.text = [tableItems objectAtIndex:indexPath.row]; //Step 4: Return the row return cell; } - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{ cell.backgroundColor = [ UIColor greenColor]; } @end Need some guidance on this.. Thanks.. Please pardon me if this is a stupid question.

    Read the article

  • iOs receivedData from NSURLConnection is nil

    - by yhl
    I was wondering if anyone could point out why I'm not able to capture a web reply. My NSLog shows that my [NSMutableData receivedData] has a length of 0 the entire run of the connection. The script that I hit when I click my login button returns a string. My NSLog result is pasted below, and after that I've pasted both the .h and .m files that I have. NSLog Result 2012-11-28 23:35:22.083 [12548:c07] Clicked on button_login 2012-11-28 23:35:22.090 [12548:c07] theConnection is succesful 2012-11-28 23:35:22.289 [12548:c07] didReceiveResponse 2012-11-28 23:35:22.290 [12548:c07] didReceiveData 2012-11-28 23:35:22.290 [12548:c07] 0 2012-11-28 23:35:22.290 [12548:c07] connectionDidFinishLoading 2012-11-28 23:35:22.290 [12548:c07] 0 ViewController.h #import <UIKit/UIKit.h> @interface ViewController : UIViewController // Create an Action for the button. - (IBAction)button_login:(id)sender; // Add property declaration. @property (nonatomic,assign) NSMutableData *receivedData; @end ViewController.m #import ViewController.h @interface ViewController () @end @implementation ViewController @synthesize receivedData; - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response { NSLog(@"didReceiveResponse"); [receivedData setLength:0]; } - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { NSLog(@"didReceiveData"); [receivedData appendData:data]; NSLog(@"%d",[receivedData length]); } - (void)connectionDidFinishLoading:(NSURLConnection *)connection { NSLog(@"connectionDidFinishLoading"); NSLog(@"%d",[receivedData length]); } - (IBAction)button_login:(id)sender { NSLog(@"Clicked on button_login"); NSString *loginScriptURL = [NSString stringWithFormat:@"http://www.website.com/app/scripts/login.php?"]; NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:loginScriptURL]]; NSString *postString = [NSString stringWithFormat:@"&paramUsername=user&paramPassword=pass"]; NSData *postData = [postString dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]; [theRequest setHTTPMethod:@"POST"]; [theRequest setHTTPBody:postData]; // Create the actual connection using the request. NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self]; // Capture the response if (theConnection) { NSLog(@"theConnection is succesful"); } else { NSLog(@"theConnection failed"); } } @end

    Read the article

< Previous Page | 2 3 4 5 6 7 8 9 10 11 12 13  | Next Page >