Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8150075
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:58:42+00:00 2026-06-06T14:58:42+00:00

Background My app takes data off a network stream, and changes values of UI

  • 0

Background

My app takes data off a network stream, and changes values of UI elements on the screen. One element is a UITextView, which serves as a sort of log for the incoming data. It is supposed to update whenever the app receives a “HasBytesAvailable” NSStreamEvent with the nature of the data incoming. (eg if the data that comes in has to do with cake, the textview would update with something like “6/22/12 8:00 – got cake”) An example of how it updates is shown below.

[logString insertString:@"This is an update\n" atIndex:0]; 
//logstring is a MutableString I use to hold my UITextView's text
[logString insertString:timeString atIndex:0]; //timestring is current time
logView.text = logString; //logView is my UITextView
[logView flashScrollIndicators];

//logstring and logview declaration and implementation
@property (nonatomic,retain) IBOutlet UITextView *logView;
@property (nonatomic,retain) NSMutableString *logString;

logString = [[NSMutableString alloc] initWithString:@"-logging started\n"];

The Problem

The updating works as I want it as long as I don’t try to scroll the TextView. However, if I scroll through the text and hold it down, presumably long enough for my update code to be called, the app crashes when I stop scrolling. I can flick through the text just fine, it’s just when it has to handle an incoming packet and I’m still scrolling that it will crash. Furthermore, while I’m scrolling, nothing else will update. All the labels that are supposed to be updated by the data received stay the same.

My Thoughts

It’s as if the app can’t handle both scrolling and working with incoming data at the same time. I’m not sure if this is because I am doing something wrong with memory management, or I need to overwrite some scrolling function, or something else entirely. Any help or thoughts is appreciated.

Solution

As trumpetlicks said, I needed to implement multithreading for my network tasks
to do this I did the following:

in initialization:

NSOperationQueue *networkQueue = [NSOperationQueue new];
NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(initNetworkCommunication) object:nil];
[networkQueue addOperation:operation];
[operation release];

in initNetworkCommunication, after initializing CFSocketpair and streams:

[[NSRunLoop currentRunLoop] run]; //necessary to handle stream events
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T14:58:43+00:00Added an answer on June 6, 2026 at 2:58 pm

    Start here.

    developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/… You may

    also wish to add your networking setup and usage code so that we can all see what you are doing there!!!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My App starts with a splash screen loading background data from remote server. After
Background: Our web app uses the jquery.constrain.js plugin to handle data entry in some
I am downloading large data from ASynchronous NSURLConnection in one separate viewcontroller.it takes 2
Background Core Data app on Snow Leopard 10.6.4 with GC I've got an NSOutlineView
Background: We have a ClickOnce-deployed WPF app, that talks to WCF Services, which in
I'm working on an app that monitors significant location changes in the background. I've
I have a mobile app, which is pretty data driven, though only through text
My app is a background service running in the foreground. In low memory situations
Background: I built an installer for my app, and all my dll's and content
Background: I'm acquireing cookies through my app and use them internally by making requests

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.